Member.php 30 KB

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