Member.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 用户控制器
  10. */
  11. class Member extends MobileMember
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize();
  16. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member_auth.lang.php');
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/goods.lang.php');
  18. }
  19. /**
  20. * @api {POST} api/Member/index 用户首页基本信息显示
  21. * @apiVersion 1.0.0
  22. * @apiGroup Member
  23. *
  24. * @apiHeader {String} X-DS-KEY 用户授权token
  25. *
  26. * @apiSuccess {String} code 返回码,10000为成功
  27. * @apiSuccess {String} message 返回消息
  28. * @apiSuccess {Object} result 返回数据
  29. * @apiSuccess {Object} result.member_info 会员信息
  30. * @apiSuccess {String} result.member_info.available_predeposit 可用预存款余额
  31. * @apiSuccess {String} result.member_info.available_rc_balance 可用充值卡余额
  32. * @apiSuccess {String} result.member_info.exppoints 当前等级所需经验值
  33. * @apiSuccess {String} result.member_info.freeze_predeposit 冻结预存款余额
  34. * @apiSuccess {String} result.member_info.freeze_rc_balance 冻结充值卡余额
  35. * @apiSuccess {String} result.member_info.inform_allow 是否允许举报(1可以/2不可以)
  36. * @apiSuccess {String} result.member_info.inviter_id 推荐人ID
  37. * @apiSuccess {String} result.member_info.inviter_state 推广员状态(0审核中1已审核2已清退)
  38. * @apiSuccess {String} result.member_info.is_allowtalk 会员是否有咨询和发送站内信的权限 1为开启 0为关闭
  39. * @apiSuccess {String} result.member_info.is_buylimit 会员是否有购买权限 1为开启 0为关闭
  40. * @apiSuccess {String} result.member_info.level 会员等级
  41. * @apiSuccess {String} result.member_info.level_name 等级名称
  42. * @apiSuccess {String} result.member_info.member_addtime 添加时间,Unix时间戳
  43. * @apiSuccess {String} result.member_info.member_areaid 地区ID
  44. * @apiSuccess {String} result.member_info.member_areainfo 地区信息
  45. * @apiSuccess {String} result.member_info.member_avatar 用户头像
  46. * @apiSuccess {String} result.member_info.member_birthday 生日
  47. * @apiSuccess {String} result.member_info.member_cityid 城市ID
  48. * @apiSuccess {String} result.member_info.member_email 邮箱
  49. * @apiSuccess {String} result.member_info.member_emailbind 已绑定邮箱 0否1是
  50. * @apiSuccess {String} result.member_info.member_exppoints 会员经验值
  51. * @apiSuccess {String} result.member_info.member_id 用户ID
  52. * @apiSuccess {String} result.member_info.member_login_ip 本次登录IP
  53. * @apiSuccess {String} result.member_info.member_loginnum 本次登录次数
  54. * @apiSuccess {String} result.member_info.member_logintime 本次登录时间,Unix时间戳
  55. * @apiSuccess {String} result.member_info.member_mobile 手机号
  56. * @apiSuccess {String} result.member_info.member_mobilebind 已绑定手机 0否1是
  57. * @apiSuccess {String} result.member_info.member_name 用户名称
  58. * @apiSuccess {String} result.member_info.member_old_login_ip 上次登录IP
  59. * @apiSuccess {String} result.member_info.member_old_logintime 上次登录时间,Unix时间戳
  60. * @apiSuccess {String} result.member_info.member_points 用户积分
  61. * @apiSuccess {String} result.member_info.member_privacy 隐私设定
  62. * @apiSuccess {String} result.member_info.member_provinceid 省份ID
  63. * @apiSuccess {String} result.member_info.member_qq 用户QQ
  64. * @apiSuccess {String} result.member_info.member_qqinfo qq快捷登录信息
  65. * @apiSuccess {String} result.member_info.member_qqopenid qq openid
  66. * @apiSuccess {String} result.member_info.member_sex 会员性别 0保密1男2女3保密
  67. * @apiSuccess {String} result.member_info.member_sinainfo 新浪快捷登录信息
  68. * @apiSuccess {String} result.member_info.member_sinaopenid 新浪openid
  69. * @apiSuccess {String} result.member_info.member_state 会员的开启状态 1为开启 0为关闭
  70. * @apiSuccess {String} result.member_info.member_truename 会员真实姓名
  71. * @apiSuccess {String} result.member_info.member_ww 用户旺旺
  72. * @apiSuccess {String} result.member_info.member_wxinfo 微信快捷登录信息
  73. * @apiSuccess {String} result.member_info.member_wxopenid 微信openid
  74. * @apiSuccess {String} result.member_info.member_wxunionid 微信unionid
  75. * @apiSuccess {String} result.member_info.order_noeval_count 待评论订单数
  76. * @apiSuccess {String} result.member_info.order_nopay_count 待付款订单数
  77. * @apiSuccess {String} result.member_info.order_noreceipt_count 待收货订单数
  78. * @apiSuccess {String} result.member_info.order_noship_count 待发货订单数
  79. * @apiSuccess {String} result.member_info.order_refund_count 退款中订单数
  80. * @apiSuccess {String} result.member_info.store_id 店铺ID
  81. * @apiSuccess {String} result.member_info.voucher_count 可用优惠券数
  82. * @apiSuccess {String} result.member_info.member_signin_time 最后一次签到时间
  83. * @apiSuccess {String} result.member_info.member_signin_days_cycle 持续签到天数,每周期后清零
  84. * @apiSuccess {String} result.member_info.member_signin_days_total 签到总天数
  85. * @apiSuccess {String} result.member_info.member_signin_days_series 持续签到天数总数,非连续周期清零
  86. */
  87. public function index()
  88. {
  89. $member_model = model('member');
  90. $member_info = $member_model->getMemberInfoByID($this->member_info['member_id']);
  91. unset($member_info['member_password']);
  92. unset($member_info['member_paypwd']);
  93. if ($member_info) {
  94. $member_gradeinfo = $member_model->getOneMemberGrade(intval($member_info['member_exppoints']));
  95. $member_info = array_merge($member_info, $member_gradeinfo);
  96. //代金券数量
  97. $member_info['voucher_count'] = model('voucher')->getCurrentAvailableVoucherCount($this->member_info['member_id']);
  98. $member_info['member_avatar'] = get_member_avatar_for_id($this->member_info['member_id']);
  99. $member_info['member_idcard_image1_url'] = get_member_idcard_image($member_info['member_idcard_image1']);
  100. $member_info['member_idcard_image2_url'] = get_member_idcard_image($member_info['member_idcard_image2']);
  101. $member_info['member_idcard_image3_url'] = get_member_idcard_image($member_info['member_idcard_image3']);
  102. }
  103. //获取用户是否有推广权限
  104. if (config('ds_config.inviter_open')) {
  105. //查看是否已是分销会员
  106. $inviter_model = model('inviter');
  107. $inviter_info = $inviter_model->getInviterInfo('i.inviter_id=' . $this->member_info['member_id']);
  108. if (!empty($inviter_info)) {
  109. $member_info['inviter_state'] = $inviter_info['inviter_state']; // 是否是分销员
  110. }
  111. }
  112. //判断此用户是否有店铺
  113. $seller_info = model('seller')->getSellerInfo(array('member_id' => $this->member_info['member_id']));
  114. if ($seller_info) {
  115. $member_info['store_id'] = $seller_info['store_id'];
  116. } else {
  117. $member_info['store_id'] = 0;
  118. }
  119. // 交易提醒
  120. $order_model = model('order');
  121. $refundreturn_model = model('refundreturn');
  122. $member_info['order_nopay_count'] = intval($order_model->getOrderCountByID('buyer', $this->member_info['member_id'], 'NewCount'));
  123. $member_info['order_noreceipt_count'] = intval($order_model->getOrderCountByID('buyer', $this->member_info['member_id'], 'SendCount'));
  124. $member_info['order_noeval_count'] = intval($order_model->getOrderCountByID('buyer', $this->member_info['member_id'], 'EvalCount'));
  125. $member_info['order_noship_count'] = intval($order_model->getOrderCountByID('buyer', $this->member_info['member_id'], 'PayCount'));
  126. $member_info['order_refund_count'] = intval($refundreturn_model->getRefundreturnCount(array(array('buyer_id', '=', $this->member_info['member_id']), array('refund_state', 'in', [1, 2]))));
  127. ds_json_encode(10000, '', array('member_info' => $member_info));
  128. }
  129. public function my_asset()
  130. {
  131. $fields_arr = array('point', 'predepoit', 'available_rc_balance', 'voucher');
  132. $fields_str = trim(input('fields'));
  133. if ($fields_str) {
  134. $fields_arr = explode(',', $fields_str);
  135. }
  136. $member_info = array();
  137. if (in_array('point', $fields_arr)) {
  138. $member_info['point'] = $this->member_info['member_points'];
  139. }
  140. if (in_array('predepoit', $fields_arr)) {
  141. $member_info['predepoit'] = $this->member_info['available_predeposit'];
  142. }
  143. if (in_array('available_rc_balance', $fields_arr)) {
  144. $member_info['available_rc_balance'] = $this->member_info['available_rc_balance'];
  145. }
  146. if (in_array('voucher', $fields_arr)) {
  147. $member_info['voucher'] = model('voucher')->getCurrentAvailableVoucherCount($this->member_info['member_id']);
  148. }
  149. ds_json_encode(10000, '', $member_info);
  150. }
  151. /**
  152. * @api {POST} api/Member/information 用户基本信息显示
  153. * @apiVersion 1.0.0
  154. * @apiGroup Member
  155. *
  156. * @apiHeader {String} X-DS-KEY 用户授权token
  157. *
  158. * @apiSuccess {String} code 返回码,10000为成功
  159. * @apiSuccess {String} message 返回消息
  160. * @apiSuccess {Object} result 返回数据
  161. * @apiSuccess {Object} result.member_info 会员信息
  162. * @apiSuccess {String} result.member_info.available_predeposit 可用预存款余额
  163. * @apiSuccess {String} result.member_info.available_rc_balance 可用充值卡余额
  164. * @apiSuccess {String} result.member_info.freeze_predeposit 冻结预存款余额
  165. * @apiSuccess {String} result.member_info.freeze_rc_balance 冻结充值卡余额
  166. * @apiSuccess {String} result.member_info.inform_allow 是否允许举报(1可以/2不可以)
  167. * @apiSuccess {String} result.member_info.inviter_id 推荐人ID
  168. * @apiSuccess {String} result.member_info.is_allowtalk 会员是否有咨询和发送站内信的权限 1为开启 0为关闭
  169. * @apiSuccess {String} result.member_info.is_buylimit 会员是否有购买权限 1为开启 0为关闭
  170. * @apiSuccess {String} result.member_info.member_addtime 添加时间,Unix时间戳
  171. * @apiSuccess {String} result.member_info.member_areaid 地区ID
  172. * @apiSuccess {String} result.member_info.member_areainfo 地区信息
  173. * @apiSuccess {String} result.member_info.member_avatar 用户头像
  174. * @apiSuccess {String} result.member_info.member_birthday 生日
  175. * @apiSuccess {String} result.member_info.member_cityid 城市ID
  176. * @apiSuccess {String} result.member_info.member_email 邮箱
  177. * @apiSuccess {String} result.member_info.member_emailbind 已绑定邮箱 0否1是
  178. * @apiSuccess {String} result.member_info.member_exppoints 会员经验值
  179. * @apiSuccess {String} result.member_info.member_id 用户ID
  180. * @apiSuccess {String} result.member_info.member_login_ip 本次登录IP
  181. * @apiSuccess {String} result.member_info.member_loginnum 登录次数
  182. * @apiSuccess {String} result.member_info.member_logintime 本次登录时间,Unix时间戳
  183. * @apiSuccess {String} result.member_info.member_mobile 手机号
  184. * @apiSuccess {String} result.member_info.member_mobilebind 已绑定手机 0否1是
  185. * @apiSuccess {String} result.member_info.member_name 用户名称
  186. * @apiSuccess {String} result.member_info.member_old_login_ip 上次登录IP
  187. * @apiSuccess {String} result.member_info.member_old_logintime 上次登录时间,Unix时间戳
  188. * @apiSuccess {String} result.member_info.member_points 用户积分
  189. * @apiSuccess {String} result.member_info.member_privacy 隐私设定
  190. * @apiSuccess {String} result.member_info.member_provinceid 省份ID
  191. * @apiSuccess {String} result.member_info.member_qq 用户QQ
  192. * @apiSuccess {String} result.member_info.member_qqinfo qq快捷登录信息
  193. * @apiSuccess {String} result.member_info.member_qqopenid qq openid
  194. * @apiSuccess {String} result.member_info.member_sex 会员性别 0保密1男2女3保密
  195. * @apiSuccess {String} result.member_info.member_sinainfo 新浪快捷登录信息
  196. * @apiSuccess {String} result.member_info.member_sinaopenid 新浪openid
  197. * @apiSuccess {String} result.member_info.member_state 会员的开启状态 1为开启 0为关闭
  198. * @apiSuccess {String} result.member_info.member_truename 会员真实姓名
  199. * @apiSuccess {String} result.member_info.member_ww 用户旺旺
  200. * @apiSuccess {String} result.member_info.member_wxinfo 微信快捷登录信息
  201. * @apiSuccess {String} result.member_info.member_wxopenid 微信openid
  202. * @apiSuccess {String} result.member_info.member_wxunionid 微信unionid
  203. */
  204. public function information()
  205. {
  206. $member_model = model('member');
  207. $condition = array();
  208. $condition[] = array('member_id', '=', $this->member_info['member_id']);
  209. $member_info = $member_model->getMemberInfo($condition);
  210. $member_info['member_avatar'] = get_member_avatar_for_id($member_info['member_id']);
  211. $member_info['member_idcard_image1_url'] = get_member_idcard_image($member_info['member_idcard_image1']);
  212. $member_info['member_idcard_image2_url'] = get_member_idcard_image($member_info['member_idcard_image2']);
  213. $member_info['member_idcard_image3_url'] = get_member_idcard_image($member_info['member_idcard_image3']);
  214. $member_info['member_birthday'] = date('Y-m-d', $member_info['member_birthday']);
  215. unset($member_info['member_password']);
  216. unset($member_info['member_paypwd']);
  217. ds_json_encode(10000, '', array('member_info' => $member_info));
  218. }
  219. /**
  220. * @api {POST} api/Member/edit_information 用户基本信息修改
  221. * @apiVersion 1.0.0
  222. * @apiGroup Member
  223. *
  224. * @apiHeader {String} X-DS-KEY 用户授权token
  225. *
  226. * @apiParam {String} member_nickname 真实姓名
  227. * @apiParam {String} member_qq 会员QQ
  228. * @apiParam {String} member_ww 会员旺旺
  229. * @apiParam {String} member_birthday 生日
  230. *
  231. * @apiSuccess {String} code 返回码,10000为成功
  232. * @apiSuccess {String} message 返回消息
  233. */
  234. public function edit_information()
  235. {
  236. $data = array(
  237. 'member_nickname' => input('param.member_nickname'),
  238. 'member_qq' => input('param.member_qq'),
  239. 'member_ww' => input('param.member_ww'),
  240. 'member_birthday' => strtotime(input('param.member_birthday')),
  241. );
  242. $member_validate = ds_validate('member');
  243. if (!$member_validate->scene('edit_information')->check($data)) {
  244. ds_json_encode(10001, $member_validate->getError());
  245. }
  246. $member_model = model('member');
  247. $condition = array();
  248. $condition[] = array('member_id', '=', $this->member_info['member_id']);
  249. $result = $member_model->editMember($condition, $data, $this->member_info['member_id']);
  250. if ($result) {
  251. ds_json_encode(10000, lang('ds_common_op_succ'));
  252. } else {
  253. ds_json_encode(10001, lang('ds_common_op_fail'));
  254. }
  255. }
  256. /**
  257. * @api {POST} api/Member/edit_memberavatar 更新用户头像
  258. * @apiVersion 1.0.0
  259. * @apiGroup Member
  260. *
  261. * @apiHeader {String} X-DS-KEY 用户授权token
  262. *
  263. * @apiParam {File} file 用户头像
  264. *
  265. * @apiSuccess {String} code 返回码,10000为成功
  266. * @apiSuccess {String} message 返回消息
  267. * @apiSuccess {String} result 用户头像
  268. */
  269. public function edit_memberavatar()
  270. {
  271. $file = request()->file('memberavatar');
  272. $upload_file = BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_AVATAR . DIRECTORY_SEPARATOR;
  273. $avatar_name = 'avatar_' . $this->member_info['member_id'] . '.jpg';
  274. $res = ds_upload_pic(ATTACH_AVATAR, 'memberavatar', $avatar_name);
  275. if ($res['code']) {
  276. $file_name = $res['data']['file_name'];
  277. if (file_exists($upload_file . '/' . $avatar_name)) {
  278. //生成缩略图
  279. $image = \think\Image::open($upload_file . '/' . $avatar_name);
  280. $image->thumb(100, 100, \think\Image::THUMB_CENTER)->save($upload_file . '/' . $avatar_name);
  281. }
  282. $member_model = model('member');
  283. $condition = array();
  284. $condition[] = array('member_id', '=', $this->member_info['member_id']);
  285. $result = $member_model->editMember($condition, array('member_avatar' => $file_name), $this->member_info['member_id']);
  286. ds_json_encode(10000, '', get_member_avatar($file_name));
  287. } else {
  288. ds_json_encode(10001, $res['msg']);
  289. }
  290. }
  291. public function goods_poster()
  292. {
  293. $goods_id = intval(input('param.goods_id'));
  294. if (!$goods_id) {
  295. ds_json_encode(10001, lang('param_error'));
  296. }
  297. $goods_model = model('goods');
  298. $goods_detail = $goods_model->getGoodsDetail($goods_id);
  299. if (empty($goods_detail)) {
  300. ds_json_encode(10001, lang('goods_goods_not_exist'));
  301. }
  302. //获取店铺信息
  303. $store_info = model('store')->getStoreInfoByID($goods_detail['goods_info']['store_id']);
  304. if (!$store_info) {
  305. ds_json_encode(10001, lang('goods_index_goods_store_closed'));
  306. }
  307. $store_info['store_avatar'] = get_store_logo($store_info['store_avatar'], 'store_avatar');
  308. !is_dir(BASE_UPLOAD_PATH . '/' . ATTACH_INVITER) && mkdir(BASE_UPLOAD_PATH . '/' . ATTACH_INVITER, 0755, true);
  309. $refer_qrcode_logo = BASE_UPLOAD_PATH . '/' . ATTACH_INVITER . '/' . $this->member_info['member_id'] . '_' . $goods_id . '_poster.png';
  310. //判断是否已生成海报
  311. if (!file_exists($refer_qrcode_logo) || 1) {
  312. //一个1080*1632的白板
  313. $back_width = 1080;
  314. $back_height = 1632;
  315. $t_logo2 = imagecreatetruecolor($back_width, $back_height);
  316. $background2 = imagecolorallocate($t_logo2, 246, 246, 246);
  317. imagefill($t_logo2, 0, 0, $background2);
  318. //定义边距
  319. $margin = 40;
  320. $font_file = PUBLIC_PATH . '/font/hyngt.ttf';
  321. $textcolor = imagecolorallocate($t_logo2, 0, 0, 0);
  322. $textcolor2 = imagecolorallocate($t_logo2, 128, 128, 128);
  323. $textcolor3 = imagecolorallocate($t_logo2, 244, 67, 54);
  324. //商品图片
  325. $goods_image = goods_cthumb($goods_detail['goods_info']['goods_image'], 1280);
  326. $logo = imagecreatefromstring(file_get_contents($goods_image));
  327. $source_info = getimagesize($goods_image);
  328. imagecopyresampled($t_logo2, $logo, 0, 0, 0, 0, $back_width, $back_width, $source_info[0], $source_info[1]);
  329. $goods_name_size = 40;
  330. $line_split = 10;
  331. $top_margin = 20;
  332. //上边距离
  333. $y = $back_width + $top_margin;
  334. //商品名称换行处理
  335. $text_array = $this->draw_txt_to(array('fontsize' => $goods_name_size, 'width' => $back_width - 2 * $margin, 'left' => 0), $goods_detail['goods_info']['goods_name']);
  336. foreach ($text_array as $text) {
  337. $y += $goods_name_size + $line_split;
  338. imagefttext($t_logo2, $goods_name_size, 0, $margin, $y, $textcolor, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  339. }
  340. //广告语
  341. $y += $top_margin;
  342. $goods_name_size = 30;
  343. $text_array = $this->draw_txt_to(array('fontsize' => $goods_name_size, 'width' => $back_width - 2 * $margin, 'left' => 0), $goods_detail['goods_info']['goods_advword']);
  344. foreach ($text_array as $text) {
  345. $y += $goods_name_size + $line_split;
  346. imagefttext($t_logo2, $goods_name_size, 0, $margin, $y, $textcolor2, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  347. }
  348. $y += $top_margin;
  349. $goods_name_size = 40;
  350. $y += $goods_name_size + $line_split;
  351. $text = '零售价:';
  352. imagefttext($t_logo2, $goods_name_size, 0, $margin, $y, $textcolor2, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  353. //价格
  354. $goods_name_size = 50;
  355. $left_temp = 250;
  356. $text = '¥' . floatval($goods_detail['goods_info']['goods_price']);
  357. imagefttext($t_logo2, $goods_name_size, 0, $left_temp, $y, $textcolor3, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  358. $y += $top_margin;
  359. //二维码
  360. $logo_size = 200;
  361. $logo = imagecreatefromstring(file_get_contents(HOME_SITE_URL . '/qrcode?url=' . urlencode(config('ds_config.h5_site_url') . '/pages/home/goodsdetail/Goodsdetail?goods_id=' . $goods_detail['goods_info']['goods_id'] . '&inviter_id=' . $this->member_info['member_id'])));
  362. $source_info = getimagesize(HOME_SITE_URL . '/qrcode?url=' . urlencode(config('ds_config.h5_site_url') . '/pages/home/goodsdetail/Goodsdetail?goods_id=' . $goods_detail['goods_info']['goods_id'] . '&inviter_id=' . $this->member_info['member_id']));
  363. imagecopyresampled($t_logo2, $logo, $margin, $y, 0, 0, $logo_size, $logo_size, $source_info[0], $source_info[1]);
  364. //长按查看商品
  365. $text = '长按或扫描二维码识别';
  366. $left_temp = $logo_size + $margin;
  367. $goods_name_size = 30;
  368. $left_top = $y + ($logo_size - $goods_name_size * 2);
  369. imagefttext($t_logo2, $goods_name_size, 0, $left_temp, $left_top, $textcolor2, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  370. $text = '查看商品详情';
  371. $left_top = $y + ($logo_size - $goods_name_size) + $line_split;
  372. imagefttext($t_logo2, $goods_name_size, 0, $left_temp, $left_top, $textcolor2, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  373. //获取店铺logo
  374. $logo_size = $logo_size - $goods_name_size * 2;
  375. $left_temp = $back_width - ($logo_size + $margin);
  376. $logo = imagecreatefromstring(file_get_contents($store_info['store_avatar']));
  377. $source_info = getimagesize($store_info['store_avatar']);
  378. imagecopyresampled($t_logo2, $logo, $left_temp, $y, 0, 0, $logo_size, $logo_size, $source_info[0], $source_info[1]);
  379. //将店铺名称放到白板上
  380. $text = $store_info['store_name'];
  381. $text_array = $this->draw_txt_to(array('fontsize' => $goods_name_size, 'width' => $back_width / 2 - $margin, 'left' => 0), $text, 1);
  382. $text = $text_array[0];
  383. $l = imagettfbbox($goods_name_size, 0, $font_file, $text);
  384. imagefttext($t_logo2, $goods_name_size, 0, $back_width - $margin - ($l[2] - $l[0]), $left_top, $textcolor2, $font_file, mb_convert_encoding($text, 'html-entities', 'UTF-8'));
  385. imagepng($t_logo2, $refer_qrcode_logo);
  386. }
  387. if (file_exists($refer_qrcode_logo)) {
  388. ds_json_encode(10000, '', array('goods_poster' => UPLOAD_SITE_URL . '/' . ATTACH_INVITER . '/' . $this->member_info['member_id'] . '_' . $goods_id . '_poster.png'));
  389. } else {
  390. ds_json_encode(10001, lang('ds_common_op_fail'));
  391. }
  392. }
  393. private function draw_txt_to($pos, $string, $line = 2)
  394. {
  395. $font_file = PUBLIC_PATH . '/font/hyngt.ttf';
  396. $_string = '';
  397. $__string = array();
  398. for ($i = 0; $i < mb_strlen($string, 'utf-8'); $i++) {
  399. $box = imagettfbbox($pos['fontsize'], 0, $font_file, $_string);
  400. $_string_length = $box[2] - $box[0];
  401. $box = imagettfbbox($pos['fontsize'], 0, $font_file, mb_substr($string, $i, 1, 'utf-8'));
  402. if ($_string_length + $box[2] - $box[0] < ($pos['width'] - $pos['left'])) {
  403. $_string .= mb_substr($string, $i, 1, 'utf-8');
  404. } else {
  405. if (count($__string) >= ($line - 1)) {
  406. $_string = mb_substr($_string, 0, mb_strlen($_string, 'utf-8') - 1, 'utf-8') . '...';
  407. break;
  408. }
  409. $pos['left'] = 0;
  410. $__string[] = $_string;
  411. $_string = mb_substr($string, $i, 1, 'utf-8');
  412. }
  413. }
  414. $__string[] = $_string;
  415. return $__string;
  416. }
  417. private function get_lt_rounder_corner($radius)
  418. {
  419. $img = imagecreatetruecolor($radius, $radius); // 创建一个正方形的图像
  420. $bgcolor = imagecolorallocate($img, 255, 255, 255); // 图像的背景
  421. $fgcolor = imagecolorallocate($img, 0, 0, 0);
  422. imagefill($img, 0, 0, $bgcolor);
  423. // $radius,$radius:以图像的右下角开始画弧
  424. // $radius*2, $radius*2:已宽度、高度画弧
  425. // 180, 270:指定了角度的起始和结束点
  426. // fgcolor:指定颜色
  427. imagefilledarc($img, $radius, $radius, $radius * 2, $radius * 2, 180, 270, $fgcolor, IMG_ARC_PIE);
  428. // 将弧角图片的颜色设置为透明
  429. imagecolortransparent($img, $fgcolor);
  430. // 变换角度
  431. // $img = imagerotate($img, 90, 0);
  432. // $img = imagerotate($img, 180, 0);
  433. // $img = imagerotate($img, 270, 0);
  434. // header('Content-Type: image/png');
  435. // imagepng($img);
  436. return $img;
  437. }
  438. public function auth()
  439. {
  440. $member_model = model('member');
  441. $member_array = array();
  442. $member_array['member_auth_state'] = 1;
  443. $member_array['member_idcard'] = input('post.member_idcard');
  444. $member_array['member_truename'] = input('post.member_truename');
  445. $member_validate = ds_validate('member');
  446. if (!$member_validate->scene('auth')->check($member_array)) {
  447. ds_json_encode(10001, $member_validate->getError());
  448. }
  449. if (!$this->member_info['member_idcard_image1']) {
  450. ds_json_encode(10001, lang('member_idcard_image1_require'));
  451. }
  452. if (!$this->member_info['member_idcard_image2']) {
  453. ds_json_encode(10001, lang('member_idcard_image2_require'));
  454. }
  455. if (!$this->member_info['member_idcard_image3']) {
  456. ds_json_encode(10001, lang('member_idcard_image3_require'));
  457. }
  458. if (!input('post.if_confirm')) {
  459. ds_json_encode(10000);
  460. }
  461. $res = $this->getIdCardInfo($this->member_info);
  462. if ($res['code'] == 200) {
  463. $info = $res['data'];
  464. if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
  465. ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
  466. }
  467. } else {
  468. ds_json_encode(10001,$res['msg']);
  469. }
  470. $update = $member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id']);
  471. $message = $update ? lang('ds_common_op_succ') : lang('ds_common_op_fail');
  472. if ($update) {
  473. ds_json_encode(10000, $message);
  474. } else {
  475. ds_json_encode(10001, $message);
  476. }
  477. }
  478. public function edit_auth()
  479. {
  480. $file_name = input('param.id');
  481. if (!empty($_FILES[$file_name]['name'])) {
  482. $res = ds_upload_pic(ATTACH_IDCARD_IMAGE, $file_name);
  483. if (!$res['code']) {
  484. ds_json_encode(10001, $res['msg']);
  485. }
  486. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  487. ds_json_encode(10001, lang('param_error'));
  488. }
  489. $member_array = array();
  490. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  491. $member_model = model('member');
  492. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  493. ds_json_encode(10001, lang('ds_common_op_fail'));
  494. }
  495. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_member_idcard_image($res['data']['file_name'])));
  496. }
  497. ds_json_encode(10001, lang('param_error'));
  498. }
  499. public function drop_auth()
  500. {
  501. $file_name = input('param.file_name');
  502. if (!in_array($file_name, array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  503. ds_json_encode(10001, lang('param_error'));
  504. }
  505. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
  506. $member_array = array();
  507. $member_array[$file_name] = '';
  508. $member_model = model('member');
  509. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  510. ds_json_encode(10001, lang('ds_common_op_fail'));
  511. }
  512. ds_json_encode(10000);
  513. }
  514. }