Member.php 30 KB

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