MerchantRepository.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-04-16
  7. *
  8. *
  9. */
  10. namespace app\common\repositories\system\merchant;
  11. use app\common\dao\system\merchant\MerchantDao;
  12. use app\common\enum\CommonEnum;
  13. use app\common\model\store\product\ProductReply;
  14. use app\common\repositories\BaseRepository;
  15. use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
  16. use app\common\repositories\store\product\ProductCopyRepository;
  17. use app\common\repositories\store\product\ProductRepository;
  18. use app\common\repositories\store\shipping\ShippingTemplateRepository;
  19. use app\common\repositories\store\StoreCategoryRepository;
  20. use app\common\repositories\system\attachment\AttachmentRepository;
  21. use app\common\repositories\user\UserRelationRepository;
  22. use app\common\repositories\user\UserVisitRepository;
  23. use app\common\repositories\wechat\RoutineQrcodeRepository;
  24. use app\controller\admin\system\merchant\MerchantIntention;
  25. use app\controller\merchant\gong\Goods;
  26. use app\entity\data\merchant\MerchantEntity;
  27. use app\traits\HaikeApiRequest;
  28. use crmeb\services\QrcodeService;
  29. use crmeb\services\UploadService;
  30. use FormBuilder\Exception\FormBuilderException;
  31. use FormBuilder\Factory\Elm;
  32. use FormBuilder\Form;
  33. use think\db\exception\DataNotFoundException;
  34. use think\db\exception\DbException;
  35. use think\db\exception\ModelNotFoundException;
  36. use think\Exception;
  37. use think\exception\ValidateException;
  38. use think\facade\Db;
  39. use think\facade\Log;
  40. use think\facade\Route;
  41. /**
  42. * Class MerchantRepository
  43. * @package app\common\repositories\system\merchant
  44. * @mixin MerchantDao
  45. * @author xaboy
  46. * @day 2020-04-16
  47. */
  48. class MerchantRepository extends BaseRepository
  49. {
  50. use HaikeApiRequest;
  51. /**
  52. * MerchantRepository constructor.
  53. * @param MerchantDao $dao
  54. */
  55. public function __construct(MerchantDao $dao)
  56. {
  57. $this->dao = $dao;
  58. }
  59. /**
  60. * @param array $where
  61. * @param $page
  62. * @param $limit
  63. * @return array
  64. * @throws DataNotFoundException
  65. * @throws DbException
  66. * @throws ModelNotFoundException
  67. * @author xaboy
  68. * @day 2020-04-16
  69. */
  70. public function lst(array $where, $page, $limit)
  71. {
  72. if (!empty($where["city"])){
  73. $city_id=Db::name("user_city")->where("city_name",$where["city"])->value("city_id");
  74. $where['city_id'] = $city_id;
  75. unset($where["city"]);
  76. }
  77. $query = $this->dao->search($where);
  78. $query = $query->with(['merchantCategory','spread']);
  79. $count = $query->count($this->dao->getPk());
  80. $list = $query->page($page, $limit)
  81. ->setOption('field', [])
  82. ->field('mer_id,merch_no, mer_name, real_name,name, mer_phone, mer_address, mark, status, create_time,is_best,recommender,category_id,type,withdrawal_setting,dc_id,merchant_level')
  83. ->select();
  84. foreach ($list as &$item) {
  85. if (!$item->withdrawal_setting && $item->merch_no != '') {
  86. try {
  87. $response = $this->merchantInfo(['merch_no' => $item->merch_no]);
  88. $item->withdrawal_setting = $response['pay_product_info']['settlement_cycle'];
  89. $item->save();
  90. } catch (\Throwable $e) {
  91. }
  92. }
  93. if($item['dc_id'] == 0){
  94. $item['dc'] = '无';
  95. }else{
  96. $item['dc'] = Db::name('big_warehouse') -> where('id',$item['dc_id']) -> value('warehouse_name');
  97. }
  98. $item['category_id']=(int)$item['category_id'];
  99. $item['status']=(int)$item['status'];
  100. $item['is_best']=(int)$item['is_best'];
  101. }
  102. unset($item);
  103. $merdata= [
  104. ['className'=> 'el-icon-s-order', 'count'=>$count, 'field'=> '个', 'name'=> '商户总数']
  105. ];
  106. return compact('count', 'list','merdata');
  107. }
  108. /**
  109. * @param array $where
  110. * @param $page
  111. * @param $limit
  112. * @return array
  113. * @throws DataNotFoundException
  114. * @throws DbException
  115. * @throws ModelNotFoundException
  116. */
  117. public function lstLeft(array $where, $page, $limit)
  118. {
  119. if (!empty($where["city"])){
  120. $city_id=Db::name("user_city")->where("city_name",$where["city"])->value("city_id");
  121. $where['city_id'] = $city_id;
  122. unset($where["city"]);
  123. }
  124. $query = $this->dao->searchLeft($where);
  125. $query = $query->with(['merchantCategory','spread']);
  126. $query = $query->withJoin(['MerchantIntention']);
  127. // $count = $query->count($this->dao->getPk());
  128. $count = $query->count('merchant.mer_id');
  129. $list = $query->page($page, $limit)
  130. ->setOption('field', [])
  131. ->field('merchant.mer_id,merchant.merch_no, merchant.mer_name, merchant.real_name,merchant.name, merchant.mer_phone, merchant.mer_address, merchant.mark, merchant.status, merchant.create_time,merchant.is_best,merchant.recommender,merchant.category_id,merchant.type,merchant.withdrawal_setting,merchant.dc_id,merchant.merchant_level')
  132. ->select();
  133. foreach ($list as &$item) {
  134. if (!$item->withdrawal_setting && $item->merch_no != '') {
  135. try {
  136. $response = $this->merchantInfo(['merch_no' => $item->merch_no]);
  137. $item->withdrawal_setting = $response['pay_product_info']['settlement_cycle'];
  138. $item->save();
  139. } catch (\Throwable $e) {
  140. }
  141. }
  142. if($item['dc_id'] == 0){
  143. $item['dc'] = '无';
  144. }else{
  145. $item['dc'] = Db::name('big_warehouse') -> where('id',$item['dc_id']) -> value('warehouse_name');
  146. }
  147. $item['category_id']=(int)$item['category_id'];
  148. $item['status']=(int)$item['status'];
  149. $item['is_best']=(int)$item['is_best'];
  150. }
  151. unset($item);
  152. $merdata= [
  153. ['className'=> 'el-icon-s-order', 'count'=>$count, 'field'=> '个', 'name'=> '商户总数']
  154. ];
  155. return compact('count', 'list','merdata');
  156. }
  157. /**
  158. * @param int|null $id
  159. * @param array $formData
  160. * @return Form
  161. * @throws FormBuilderException
  162. * @author xaboy
  163. * @day 2020-04-16
  164. */
  165. public function form(?int $id = null, array $formData = [])
  166. {
  167. $form = Elm::createForm(is_null($id) ? Route::buildUrl('systemMerchantCreate')->build() : Route::buildUrl('systemMerchantUpdate_1', ['id' => $id])->build());
  168. /** @var MerchantCategoryRepository $make */
  169. $make = app()->make(MerchantCategoryRepository::class);
  170. // $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']);
  171. $formData['category_id']=(int)$formData['category_id'];
  172. $formData['status']=(int)$formData['status'];
  173. $formData['is_audit']=(int)$formData['is_audit'];
  174. $formData['is_best']=(int)$formData['is_best'];
  175. $rule = [
  176. Elm::input('mer_name', '商户名称')->required(),
  177. // Elm::select('mer_type', '一壶茶会员专区商户')->options(function () {
  178. // return array(
  179. // array('value'=>'0','label'=>'普通商户'),
  180. // array('value'=>'1','label'=>'一壶茶会员专区商户'),
  181. // );
  182. // })->required(),
  183. Elm::select('category_id', '商户分类')->options(function () use ($make) {
  184. $data = $make->allOptions();
  185. $options = [];
  186. foreach ($data as $value => $label) {
  187. $options[] = compact('value', 'label');
  188. }
  189. return $options;
  190. })->requiredNum(),
  191. Elm::input('mer_account', '商户账号')->required()->disabled(!is_null($id))->required(!is_null($id)),
  192. Elm::password('mer_password', '登录密码')->required()->disabled(!is_null($id))->required(!is_null($id)),
  193. Elm::input('real_name', '商户姓名'),
  194. Elm::input('mer_phone', '商户手机号')->col(12),
  195. // Elm::number('commission_rate', '手续费(%)')->col(12),
  196. Elm::input('mer_keyword', '商户关键字')->col(12),
  197. Elm::input('mer_address', '商户地址'),
  198. Elm::input('lng', '经度')->col(12),
  199. Elm::input('lat', '纬度')->col(12),
  200. Elm::textarea('mark', '备注'),
  201. Elm::number('sort', '排序', 0),
  202. Elm::switches('status', '是否开启', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启')->col(12),
  203. //Elm::switches('is_bro_room', '直播间审核', $config['broadcast_room_type'] == 1 ? 0 : 1)->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启')->col(12),
  204. Elm::switches('is_audit', '产品审核', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启')->col(12),
  205. //Elm::switches('is_bro_goods', '直播间商品审核', $config['broadcast_goods_type'] == 1 ? 0 : 1)->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启')->col(12),
  206. Elm::switches('is_best', '是否推荐')->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启'),
  207. Elm::switches('is_show_alibaba', '阿里巴巴')->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启'),
  208. ];
  209. $form->setRule($rule);
  210. return $form->setTitle(is_null($id) ? '添加商户' : '编辑商户')->formData($formData);
  211. }
  212. /**
  213. * @param array $formData
  214. * @return Form
  215. * @throws FormBuilderException
  216. * @author xaboy
  217. * @day 2020/6/25
  218. */
  219. public function merchantForm(array $formData = [])
  220. {
  221. if(isset($formData['mer_state'])){$formData['mer_state']=(int)$formData['mer_state'];}
  222. $form = Elm::createForm(Route::buildUrl('merchantUpdate')->build());
  223. $rule = [
  224. Elm::input('mer_phone', '手机号')->readonly(true),
  225. Elm::input('email', '邮箱')->readonly(true),
  226. Elm::input('product_score', '商品描述评分')->readonly(true),
  227. Elm::input('service_score', '服务评分')->readonly(true),
  228. Elm::input('postage_score', '物流评分')->readonly(true),
  229. Elm::input('care_count', '关注总数')->readonly(true),
  230. Elm::input('bank_location', '开户所在地')->readonly(true),
  231. Elm::input('bank_deposit', '开户行')->readonly(true),
  232. Elm::input('bank_branch', '开户支行')->readonly(true),
  233. Elm::input('bank_account', '开户账号')->readonly(true),
  234. Elm::input('open_account', '开户许可证')->readonly(true),
  235. // Elm::input('district_addr', '商圈')->required(),
  236. Elm::textarea('mer_info', '店铺简介')->required(),
  237. Elm::input('service_phone', '服务电话')->required(),
  238. Elm::frameImage('mer_banner', '店铺 banner', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=mer_banner&type=1')->modal(['modal' => false])->width('896px')->height('480px')->props(['footer' => false]),
  239. Elm::frameImage('mer_avatar', '店铺头像', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=mer_avatar&type=1')->modal(['modal' => false])->width('896px')->height('480px')->props(['footer' => false]),
  240. Elm::switches('mer_state', '是否开启', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关闭')->activeText('开启')->col(12),
  241. ];
  242. $form->setRule($rule);
  243. return $form->setTitle('编辑店铺信息')->formData($formData);
  244. }
  245. /**
  246. * @param $id
  247. * @return Form
  248. * @throws FormBuilderException
  249. * @throws DataNotFoundException
  250. * @throws DbException
  251. * @throws ModelNotFoundException
  252. * @author xaboy
  253. * @day 2020-04-16
  254. */
  255. public function updateForm($id)
  256. {
  257. $data = $this->dao->get($id)->toArray();
  258. /** @var MerchantAdminRepository $make */
  259. $make = app()->make(MerchantAdminRepository::class);
  260. $data['mer_account'] = $make->merIdByAccount($id);
  261. $data['mer_password'] = '***********';
  262. return $this->form($id, $data);
  263. }
  264. /**
  265. * @param array $data
  266. * @author xaboy
  267. * @day 2020-04-17
  268. */
  269. public function createMerchant(array $data)
  270. {
  271. /** @var MerchantAdminRepository $make */
  272. $make = app()->make(MerchantAdminRepository::class);
  273. Db::transaction(function () use ($data, $make) {
  274. $account = $data['mer_account'];
  275. $password = $data['mer_password'];
  276. unset($data['mer_account'], $data['mer_password']);
  277. $merchant = $this->dao->create($data);
  278. $make->createMerchantAccount($merchant, $account, $password);
  279. app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id);
  280. app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id);
  281. });
  282. }
  283. /**
  284. * @Author:Qinii
  285. * @Date: 2020/5/30
  286. * @param $where
  287. * @param $page
  288. * @param $limit
  289. * @return array
  290. */
  291. public function getList($where, $page, $limit, $userInfo)
  292. {
  293. $where['status'] = 1;
  294. $where['mer_state'] = 1;
  295. if ($userInfo && $where['keyword'] !== '')
  296. app()->make(UserVisitRepository::class)->searchMerchant($userInfo['uid'], $where['keyword']);
  297. if($where['category_id'] == 0) {
  298. unset($where['category_id']);
  299. $query = $this->dao->search($where)->with(['showProduct']);
  300. $query = $query->order("create_time desc")->limit("10");
  301. }else{
  302. $query = $this->dao->search($where)->with(['showProduct']);
  303. }
  304. $count = $query->count($this->dao->getPk());
  305. $list = $query->page($page, $limit)->setOption('field', [])
  306. ->field('lat,lng,addr,mer_id,mer_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,category_id')
  307. ->select()
  308. ->each(function ($item) {
  309. $data = $item->showProduct->toArray();
  310. unset($item->showProduct);
  311. $recommend = array_slice($data, 0, 3);
  312. return $item['recommend'] = $recommend;
  313. });
  314. return compact('count', 'list');
  315. }
  316. /**
  317. * @Author:Qinii
  318. * @Date: 2020/5/30
  319. * @param int $id
  320. * @return array|\think\Model|null
  321. */
  322. public function merExists(int $id)
  323. {
  324. return ($this->dao->get($id));
  325. }
  326. /**
  327. * @Author:Qinii
  328. * @Date: 2020/5/30
  329. * @param $id
  330. * @param $userInfo
  331. * @return array|\think\Model|null
  332. */
  333. public function detail($id, $userInfo, $lat='', $lng='')
  334. {
  335. $merchant = $this->dao->apiGetOne($id)->hidden(["real_name", "mer_phone", "reg_admin_id", "sort", "is_del", "is_audit", "is_best", "mer_state", "bank", "bank_number", "bank_name", 'update_time']);
  336. $merchant['care'] = false;
  337. $merchant['like']=false;
  338. $merchant['topping']=false;
  339. if ($userInfo){
  340. $like=Db::name('store_fabulous')->where(['uid'=>$userInfo->uid,'mer_id'=>$id])->value('status');
  341. if($like==1){
  342. $like=true;
  343. }else{
  344. $like=false;
  345. }
  346. if($userInfo->mer_topping==$id){
  347. $topping=true;
  348. }else{
  349. $topping=false;
  350. }
  351. $merchant['care'] = $this->getCareByUser($id, $userInfo->uid);
  352. $merchant['like']=$like;
  353. $merchant['topping']=$topping;
  354. }
  355. // Db::name("merchant")->where("mer_id",$cartInfo['mer_id'])->inc('renqizhi', 1)
  356. $this->dao->addrenqi($id);
  357. if($merchant['content_pic']){
  358. $merchant['content_pic'] = explode(',',$merchant['content_pic']);
  359. }
  360. $lat=empty($lat)?"34.73841":$lat;
  361. $lng=empty($lng)?"113.643636":$lng;
  362. $field = 'ACOS(SIN(('.$lat.' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(('.$lat.' * 3.1415) / 180 )
  363. * COS((lat * 3.1415) / 180 ) *COS(('.$lng.' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380 as distance';
  364. $distance =Db::name("merchant")
  365. ->where("mer_id",$id)
  366. ->field($field)
  367. ->find();
  368. $merchant['distance'] =sprintf("%.2f",$distance['distance']);
  369. return $merchant;
  370. }
  371. /**
  372. * @Author:Qinii
  373. * @Date: 2020/5/30
  374. * @param int $merId
  375. * @param int $userId
  376. * @return bool
  377. */
  378. public function getCareByUser(int $merId, int $userId)
  379. {
  380. if (app()->make(UserRelationRepository::class)->getWhere(['type' => 10, 'type_id' => $merId, 'uid' => $userId]))
  381. return true;
  382. return false;
  383. }
  384. /**
  385. * @Author:Qinii
  386. * @Date: 2020/5/30
  387. * @param $merId
  388. * @param $where
  389. * @param $page
  390. * @param $limit
  391. * @param $userInfo
  392. * @return mixed
  393. */
  394. public function productList($merId, $where, $page, $limit, $userInfo,$type439=false,$is_commercetrade = 0)
  395. {
  396. // log::info("========j进入prodctList");
  397. // log::info($merId);
  398. // log::info( $where);
  399. // log::info($userInfo);
  400. // log::info($type439);
  401. $list=app()->make(ProductRepository::class)->getApiSearch($merId, $where, $page, $limit, $userInfo,$type439);
  402. $arr=[];
  403. foreach ($list["list"] as $v){
  404. $k= app()->make(ProductRepository::class)->pvParm($v['product_id']);
  405. $productMerId = $v['mer_id'] ?? 0;
  406. // $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
  407. // log::info("==========yang= {$k['yanglao']} ");
  408. $v['yanglao']='';
  409. $v['pv']='';
  410. $v['jifen']='';
  411. $v['gongxian']='';
  412. $v['jfduihuan']='';
  413. $v['jdduihuan']='';
  414. //会员专区中VR或者现金和VR+现金形式
  415. //支付组合
  416. $v['fzone_paytype'] = '';
  417. //$v['vr'] = 0;
  418. $num_yl = 0;
  419. if($v['price'] == '1180'){
  420. $num_yl = 1000;
  421. }else if($v['price'] == '10620'){
  422. $num_yl = 9000;
  423. }else if($v['price'] == '11800'){
  424. $num_yl = 10000;
  425. }else if($v['price'] == '2360'){
  426. $num_yl = 2000;
  427. }else if($v['price'] == '9440'){
  428. $num_yl = 8000;
  429. }else if($v['price'] == '5900'){
  430. $num_yl = 5000;
  431. }
  432. if($productMerId == 496){
  433. $v['yanglao'] = bcmul($num_yl, 0.035, 2);
  434. $v['pv'] = bcmul($num_yl, 0.7, 2);
  435. //$v['vr']=$v['price'];
  436. //1:为会员专区,
  437. $v['fzone_paytype']= [
  438. 1=>[
  439. 1=>$v['price'],//VR
  440. 2=>$v['price']//现金
  441. ]
  442. ];
  443. }else if($productMerId == 439 || $is_commercetrade){
  444. //精彩生活和商贸区
  445. $jf = $v['price'] - bcmul($v['concession_pri'],0.3, 2) . ' + ' . bcmul($v['concession_pri'],0.3, 2);
  446. $jd = $v['price'] - bcmul($v['concession_pri'],0.35, 2) . ' + ' . bcmul($v['concession_pri'],0.35, 2);
  447. if($v['concession_pri'] !=null || $v['concession_pri'] !=0){
  448. $v['yanglao'] = bcmul($v['concession_pri'],0.3, 2);
  449. $v['pv'] = bcmul($v['concession_pri'],0.35, 2);
  450. $v['jfduihuan'] =$jf;
  451. $v['jdduihuan'] = $jd;
  452. $v['jifen'] = bcmul($v['concession_pri'], 0.35, 2);
  453. $v['gongxian'] = bcmul($v['concession_pri'], 0.35, 2);
  454. }
  455. }else if($productMerId == 491){
  456. // 获取商品sku
  457. $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
  458. $pv = $productSku['plate_mer_profit']??0.00;
  459. // $num_yl = $v['price'];
  460. // $pv= $num_yl * 0.3;
  461. // $yanglao = bcmul($pv, 0.5, 2);
  462. $yanglao = 0;
  463. $v['pv'] = $pv;
  464. $v['yanglao'] = $yanglao;
  465. $v['fzone_paytype']= [
  466. 1=>[
  467. 1=>$v['price'],//VR
  468. 2=>$v['price'],//现金
  469. 3=>$v['price']//复购金
  470. ]
  471. ];
  472. }else if ($productMerId == 3447) {
  473. $yanglao = bcmul($v['price'], CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], 2);
  474. $v['yanglao'] = $yanglao;
  475. // 计算共富区PV
  476. /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
  477. $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
  478. // 共富配置---获取最大推荐奖
  479. $sharedProsperityRecommendConfigEntityByMaxRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
  480. // 共富配置--获取最大的分享奖比例
  481. $sharedProsperityRecommendConfigEntityByMaxShareRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxShareRatio();
  482. // 利润 减去 顶格的直推奖,剩下的是PV值
  483. $sharPveRate = bcadd($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(),$sharedProsperityRecommendConfigEntityByMaxShareRewardRatio->getShareRatio(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
  484. $pvProportion = bcsub('1', bcdiv($sharPveRate, '100', 4), 2);
  485. // 获取利润
  486. $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
  487. // 计算pv
  488. $pv = bcmul($productSku['plate_mer_profit'], $pvProportion, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
  489. $v['pv'] = $pv;
  490. }
  491. if ($v['pension_is'] != 0) {
  492. $v['yanglao'] = $v['pension'];
  493. }
  494. // $v=($v,$k);
  495. // array_push($v,$k);
  496. $arr[]=$v;
  497. }
  498. $list["merId"]=$merId;
  499. $list["list"]=$arr;
  500. return $list;
  501. }
  502. public function productList_yhc($merId, $where, $page, $limit, $userInfo)
  503. {
  504. unset($where['order']);
  505. if (isset($where['price_on']) && $where['price_on'] != '')$where['price'] = [$where['price_asc'], $where['price_desc']];
  506. if (isset($where['brand_id']) && $where['brand_id'] != '') $where['brand_id'] = explode(',', $where['brand_id']);
  507. unset($where['price_on'], $where['price_off']);
  508. //搜索记录
  509. if ($userInfo && isset($where['keyword']) && !empty($where['keyword']))
  510. app()->make(UserVisitRepository::class)->searchProduct($userInfo['uid'], $where['keyword']);
  511. $query = Db::name('store_product')->where('product_id','>',0)->where('mer_id', $merId)->where('type', 17);
  512. $keyArray = $whereArr = [];
  513. unset($where['type']);
  514. foreach ($where as $key => $item) {
  515. if ($item !== '' && $key != 'soft') {
  516. $keyArray[] = $key;
  517. $whereArr[$key] = $item;
  518. }
  519. }
  520. unset($whereArr['order']);
  521. $query->withSearch($keyArray, $whereArr)->where('is_show',1)->where('status',1);
  522. $query->when(isset($where['keyword']) && $where['keyword'] != '', function ($query) use ($where) {
  523. $query->whereLike('store_name', "%{$where['keyword']}%");
  524. unset($where['keyword']);
  525. });
  526. $query->order('sort DESC ,create_time DESC');
  527. $query->with(['merchant'])->with(['issetCoupon']);
  528. $count = $query->count();
  529. // echo DB::getlastsql();die;
  530. $filed = 'product_id,mer_id,brand_id,unit_name,rate,reply_count,store_info,cate_id,ficti,image,slider_image,store_name,keyword,sort,is_show,sales,price,refusal,cost,ot_price,stock,is_gift_bag,care_count,status,is_used,create_time,seckill,plate_mer_profit,type';
  531. $list = $query->page($page, $limit)->setOption('field', [])->field($filed)->select();
  532. $ProductRepository=app()->make(ProductRepository::class);
  533. $list->each(function ($item) use ($ProductRepository) {
  534. $item['sales'] = $item['sales'] + $item['ficti'];
  535. unset($item['ficti']);
  536. $item['yanglao'] = $ProductRepository->yanglaojin($item['product_id']);
  537. return $item;
  538. });
  539. // if ($this->getUserIsPromoter($userInfo)) $list = $list->each(function ($item) {
  540. // return $item['max_extension'] = $item->max_extension;
  541. // });
  542. $list= compact('count', 'list');
  543. $arr=[];
  544. foreach ($list["list"] as $v){
  545. $v['yanglao']= app()->make(ProductRepository::class)->yanglaojin($v['product_id']);
  546. $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
  547. $arr[]=$v;
  548. }
  549. $list["list"]=$arr;
  550. return $list;
  551. }
  552. /**
  553. * @Author:Qinii
  554. * @Date: 2020/5/30
  555. * @param int $id
  556. * @return mixed
  557. */
  558. public function categoryList(int $id)
  559. {
  560. return app()->make(StoreCategoryRepository::class)->getApiFormatList($id, 1);
  561. }
  562. public function offlineUserQrcode($merId, $userId,$queryString = '/h5payment/index.html', $imgName = '_store_user_offline_wap.jpg')
  563. {
  564. $siteUrl = systemConfig('site_url');
  565. $name = $merId . $userId . $imgName;
  566. $attachmentRepository = app()->make(AttachmentRepository::class);
  567. $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]);
  568. if (isset($imageInfo['attachment_src']) && strstr($imageInfo['attachment_src'], 'http') !== false && curl_file_exist($imageInfo['attachment_src']) === false) {
  569. $imageInfo->delete();
  570. $imageInfo = null;
  571. }
  572. if (!$imageInfo) {
  573. $codeUrl = set_http_type(rtrim($siteUrl, '/') . $queryString.'?id=' . $merId . '&user_id=' . $userId, request()->isSsl() ? 0 : 1);//二维码链接
  574. $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($codeUrl, $name);
  575. if (is_string($imageInfo)) throw new ValidateException('二维码生成失败');
  576. $imageInfo['dir'] = path_to_url($imageInfo['dir']);
  577. if (strpos($imageInfo['dir'], 'http') === false) $imageInfo['dir'] = request()->domain() . $imageInfo['dir'];
  578. $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $merId, [
  579. 'attachment_category_id' => 0,
  580. 'attachment_name' => $imageInfo['name'],
  581. 'attachment_src' => $imageInfo['dir']
  582. ]);
  583. $urlCode = $imageInfo['dir'];
  584. } else $urlCode = $imageInfo['attachment_src'];
  585. return $urlCode;
  586. }
  587. public function wxQrcode($merId, $queryString = '/pages/store/home/index', $imgName = '_store_wap.jpg', $avatar = '')
  588. {
  589. $siteUrl = systemConfig('site_url');
  590. $name = $merId . $imgName;
  591. $attachmentRepository = app()->make(AttachmentRepository::class);
  592. $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]);
  593. if (isset($imageInfo['attachment_src']) && strstr($imageInfo['attachment_src'], 'http') !== false && curl_file_exist($imageInfo['attachment_src']) === false) {
  594. $imageInfo->delete();
  595. $imageInfo = null;
  596. }
  597. if (!$imageInfo) {
  598. $codeUrl = set_http_type(rtrim($siteUrl, '/') . $queryString.'?id=' . $merId, request()->isSsl() ? 0 : 1);//二维码链接
  599. $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($codeUrl, $name, $avatar);
  600. if (is_string($imageInfo)) throw new ValidateException('二维码生成失败');
  601. $imageInfo['dir'] = path_to_url($imageInfo['dir']);
  602. if (strpos($imageInfo['dir'], 'http') === false) $imageInfo['dir'] = request()->domain() . $imageInfo['dir'];
  603. $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $merId, [
  604. 'attachment_category_id' => 0,
  605. 'attachment_name' => $imageInfo['name'],
  606. 'attachment_src' => $imageInfo['dir']
  607. ]);
  608. $urlCode = $imageInfo['dir'];
  609. } else $urlCode = $imageInfo['attachment_src'];
  610. return $urlCode;
  611. }
  612. public function routineQrcode($merId, $queryString = '/pages/store/home/index', $imgName = '_store_routine.jpg')
  613. {
  614. $name = $merId . $imgName;
  615. $attachmentRepository = app()->make(AttachmentRepository::class);
  616. $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]);
  617. if (isset($imageInfo['attachment_src']) && strstr($imageInfo['attachment_src'], 'http') !== false && curl_file_exist($imageInfo['attachment_src']) === false) {
  618. $imageInfo->delete();
  619. $imageInfo = null;
  620. }
  621. if (!$imageInfo) {
  622. $uploadType = (int)systemConfig('upload_type') ?: 1;
  623. $routineQrcodeRepository = app()->make(RoutineQrcodeRepository::class);
  624. $res = $routineQrcodeRepository->getShareCode($merId, 'store', $queryString.'?id=' . $merId, '');
  625. if (!$res) throw new ValidateException('二维码生成失败');
  626. $upload = UploadService::create($uploadType);
  627. $uploadRes = $upload->to('routine/spread/code')->validate()->stream($res['res'], $name);
  628. if ($uploadRes === false) {
  629. throw new ValidateException($upload->getError());
  630. }
  631. $imageInfo = $upload->getUploadInfo();
  632. $imageInfo['image_type'] = $uploadType;
  633. $imageInfo['dir'] = path_to_url($imageInfo['dir']);
  634. if (strpos($imageInfo['dir'], 'http') === false) $imageInfo['dir'] = request()->domain() . $imageInfo['dir'];
  635. $attachmentRepository->create($uploadType, -2, $merId, [
  636. 'attachment_category_id' => 0,
  637. 'attachment_name' => $imageInfo['name'],
  638. 'attachment_src' => $imageInfo['dir']
  639. ]);
  640. $routineQrcodeRepository->setRoutineQrcodeFind($res['id'], ['status' => 1, 'url_time' => date('Y-m-d H:i:s'), 'qrcode_url' => $imageInfo['dir']]);
  641. $urlCode = $imageInfo['dir'];
  642. } else $urlCode = $imageInfo['attachment_src'];
  643. return $urlCode;
  644. }
  645. public function copyForm(int $id)
  646. {
  647. $form = Elm::createForm(Route::buildUrl('systemMerchantChangeCopy', ['id' => $id])->build());
  648. $form->setRule([
  649. Elm::radio('type', '修改类型', 1)
  650. ->setOptions([
  651. ['value' => 1, 'label' => '增加'],
  652. ['value' => 2, 'label' => '减少'],
  653. ]),
  654. Elm::number('num', '修改数量', $this->dao->getCopyNum($id))->required()
  655. ]);
  656. return $form->setTitle('修改复制商品次数');
  657. }
  658. /**
  659. * @Author:Qinii
  660. * @Date: 2020/10/10
  661. * @param $where
  662. * @param $page
  663. * @param $limit
  664. * @return array
  665. */
  666. public function getLists($data, $page, $limit, $type=1,$where=[])
  667. {
  668. $where['status'] = 1;
  669. $where['mer_state'] = 1;
  670. $field = 'ACOS(SIN(('.$data["lat"].' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(('.$data["lat"].' * 3.1415) / 180 )
  671. * COS((lat * 3.1415) / 180 ) *COS(('.$data["lng"].' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380 as distance';
  672. $fields =$field.',mer_id,mer_name,mark,mer_avatar,status,create_time,category_id,district_addr,care_count,renqizhi,sales';
  673. if (!empty($data["city_name"])){
  674. $city_id=Db::name("user_city")->where("city_name",$data["city_name"])->value("city_id");
  675. $where['city_id'] = $city_id;
  676. }
  677. if ($type==1) {
  678. if ( empty($where['category_id'])){
  679. $order = "mer_id desc";
  680. }else{
  681. $where['is_best'] = 1;
  682. $order = "mer_id desc,distance asc";
  683. }
  684. }else if($type==2){
  685. if ($data["order"]==1){
  686. $order = "distance asc";
  687. }else{
  688. $order = ['care_count'=>'desc'];
  689. }
  690. }
  691. $query = $this->dao->search($where);
  692. $count = $query->count($this->dao->getPk());
  693. $list =Db::name("merchant")
  694. ->where($where)
  695. ->page($page, $limit)
  696. ->field($fields)
  697. // ->having('distance <= '.'10000')
  698. ->order($order)
  699. ->select()
  700. ->each(function ($item) {
  701. $item['label'] ="人气";
  702. // $item['sales'] =$item["renqizhi"];
  703. $item['distance'] =sprintf("%.2f",$item['distance']);
  704. $item['classify'] =Db::name('merchant_category')->where("merchant_category_id",$item["category_id"])->value("category_name");
  705. // var_dump(merchantConfig($item['mer_id'], 'printing_client_id'));exit();
  706. // $yanglao=merchantConfig($item['mer_id'], 'printing_client_id')/100;
  707. $base_commission=merchantConfig($item['mer_id'], 'base_commission');
  708. if($base_commission <= 0){
  709. $base_commission= systemConfig("extension_one_rate");
  710. }
  711. //商户养老金比例
  712. $yanglao= floatval(merchantConfig($item['mer_id'], 'yanglaojin'));
  713. if(!$yanglao){
  714. //若商户养老金比例不存在 则使用平台配置
  715. $yanglao = systemConfig('yanglaojin_admin');
  716. }
  717. $item['yanglao'] = bcmul($base_commission, $yanglao ,2) * 0.01;
  718. return $item;
  719. })->toArray();
  720. $counts=count($list);
  721. if( $counts<10 && $type==1){
  722. $ids=[];
  723. foreach($list as $v){
  724. $ids[]=$v["mer_id"];
  725. }
  726. $city_id=$where["city_id"];
  727. unset($where["city_id"]);
  728. $lists =Db::name("merchant")
  729. ->where($where)
  730. ->where("city_id","<>",$city_id)
  731. ->where("mer_id","<>",implode(",",$ids))
  732. ->page(1, 10-$counts)
  733. ->field($fields)
  734. ->order("distance asc")
  735. ->select()
  736. ->each(function ($item) {
  737. $item['label'] ="人气";
  738. // $item['sales'] =$item["renqizhi"];
  739. $item['distance'] =sprintf("%.2f",$item['distance']);
  740. $item['classify'] =Db::name('merchant_category')->where("merchant_category_id",$item["category_id"])->value("category_name");
  741. $base_commission=merchantConfig($item['mer_id'], 'base_commission');
  742. if($base_commission <= 0){
  743. $base_commission= systemConfig("extension_one_rate");
  744. }
  745. //商户养老金比例
  746. $yanglao= floatval(merchantConfig($item['mer_id'], 'yanglaojin'));
  747. if(!$yanglao){
  748. //若商户养老金比例不存在 则使用平台配置
  749. $yanglao = systemConfig('yanglaojin_admin');
  750. }
  751. $item['yanglao'] = bcmul($base_commission, $yanglao ,2) * 0.01;
  752. return $item;
  753. })->toArray();
  754. $list=array_merge($list,$lists);
  755. }
  756. return compact('count', 'list','where');
  757. }
  758. /**
  759. * @Date: 2020/10/31
  760. * @param $where
  761. * @param $page
  762. * @param $limit
  763. * @return array
  764. * @author cabbage
  765. */
  766. public function getLst($data, $page, $limit,$where=[])
  767. {
  768. //下过单的店铺
  769. $mer_ids="";
  770. if (!empty($data["user_id"])){
  771. $mer_ids=Db::name('store_order')->where("uid",$data["user_id"])->order("order_id desc")->column("mer_id");
  772. if ($mer_ids){
  773. $mer_ids=array_unique($mer_ids);
  774. }
  775. }
  776. $where['status'] = 1;
  777. $where['mer_state'] = 1;
  778. $where['sxy_submerchant_id'] = 1;
  779. $field = '';
  780. if(!empty($data['lat']) && !empty($data['lng'])){
  781. $field = 'ACOS(SIN(('.$data["lat"].' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(('.$data["lat"].' * 3.1415) / 180 )
  782. * COS((lat * 3.1415) / 180 ) *COS(('.$data["lng"].' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380 as distance,';
  783. }else{
  784. $field = "mer_id as distance";
  785. }
  786. $fields =$field.'mer_id,mer_name,mark,mer_avatar,sales,status,create_time,category_id,care_count,sales,district_addr,renqizhi';
  787. if ($mer_ids){
  788. $order = [
  789. "FIELD (id,{$mer_ids})"=>'desc',
  790. 'sales'=>'desc', //销量
  791. 'care_count'=>'desc', //关注
  792. 'distance'=>"asc"//距离
  793. ];
  794. }else{
  795. $order = [
  796. 'distance'=>"asc",//距离
  797. 'sales'=>'desc', //销量
  798. 'care_count'=>'desc', //关注
  799. ];
  800. }
  801. if($data["order"]==1){
  802. $order = [
  803. 'distance'=>"asc",//距离
  804. 'sales'=>'asc',
  805. 'care_count'=>'asc',
  806. ];
  807. }
  808. $data['distance'] = ($data['distance']&&$data['distance']!=50)?$data['distance']:8000;
  809. $query = $this->dao->search_mer($where);
  810. $count = $query->count($this->dao->getPk());
  811. $list = $query
  812. ->page($page, $limit)
  813. ->setOption('field', [])
  814. ->field($fields)
  815. ->having('distance <= '.$data['distance'])
  816. ->order($order)
  817. ->select()
  818. ->each(function ($item) {
  819. $item['popularity'] =$item["renqizhi"];
  820. $item['sales'] =$item["sales"];
  821. $item['distance'] =sprintf("%.2f",$item['distance']);
  822. if ( $item['distance']<=10){
  823. $item['label'] ="附近";
  824. }else{
  825. $item['label'] ="附近";
  826. }
  827. $item['classify'] =Db::name('merchant_category')->where("merchant_category_id",$item["category_id"])->value("category_name");
  828. $base_commission=merchantConfig($item['mer_id'], 'base_commission');
  829. if($base_commission <= 0){
  830. $base_commission= systemConfig("extension_one_rate");
  831. }
  832. //商户养老金比例
  833. $yanglao= floatval(merchantConfig($item['mer_id'], 'yanglaojin'));
  834. if(!$yanglao){
  835. //若商户养老金比例不存在 则使用平台配置
  836. $yanglao = systemConfig('yanglaojin_admin');
  837. }
  838. $item['yanglao'] = bcmul($base_commission, $yanglao ,2) * 0.01;
  839. return $item;
  840. });
  841. return compact('count', 'list','order','where');
  842. }
  843. /**
  844. *
  845. * @param $page
  846. * @param $limit
  847. * @return array
  848. */
  849. public function merchantcategory()
  850. {
  851. return Db::name('merchant_category')->where("status",1)->order("order_sort desc,merchant_category_id desc")->select()->toArray();
  852. }
  853. /*商家分类列表*/
  854. public function mercat($page, $limit)
  855. {
  856. $count= Db::name('merchant_category')->count();
  857. $list= Db::name('merchant_category')->where("status",1)->order("order_sort desc,merchant_category_id desc")->select()->toArray();
  858. return compact('count', 'list');
  859. }
  860. /**
  861. * @param $id
  862. * @return Form
  863. * @throws FormBuilderException
  864. * @author xaboy
  865. * @day 2020-05-07
  866. */
  867. public function changeProForm($id)
  868. {
  869. return Elm::createForm(Route::buildUrl('systemMerchantChangePro', compact('id'))->build(), [
  870. Elm::input('spread_account', '推荐人')->required()->value("请填写推荐人手机号")
  871. ])->setTitle('修改商户推荐人');
  872. }
  873. /*
  874. * 修改商户推广人id
  875. *@author cabbage
  876. *@date 2020-10-31
  877. * */
  878. public function update_spread($id,$spread_account){
  879. //推荐人信息
  880. $spread = Db::name("user")->where('account',$spread_account)->value("uid");
  881. $mer_uid = Db::name("merchant")->where(['mer_id'=>$id])->value("uid");
  882. if($spread && $mer_uid){
  883. try{
  884. Db::name("user")->where(["uid"=>$mer_uid])->update(['spread_uid'=>$spread]);
  885. Db::name("merchant")->where(["mer_id"=>$id])->update(['recommender'=>$spread]);
  886. return true;
  887. }catch (Exception $e) {
  888. Db::rollback();
  889. }
  890. }else{
  891. return false;
  892. }
  893. }
  894. /*下架商品*/
  895. public function MerUpdate($where,$data)
  896. {
  897. return Db::name("store_product")->where($where)->update($data);
  898. }
  899. /*推荐商品*/
  900. public function getProductGoodList($id){
  901. $where['is_gift_bag'] = 0;
  902. $where['is_used'] = 1;
  903. $where['product_type'] = 0;
  904. $where['mer_id'] = $id;
  905. $where['is_good'] = 1;
  906. return Db::name("store_product")->where($where)->field("image,product_id,store_name as title,price,ot_price")->select();
  907. }
  908. /*收款二维码*/
  909. public function getQrCode($mer){
  910. $res = Db::name("MerchantQrcode")
  911. -> where("mer_id",$mer -> mer_id)
  912. -> field("qrcode_src as url,show_src")
  913. -> find();
  914. if(!$res || $res['url'] == '' || $res['show_src'] == ''){
  915. Db::name("MerchantQrcode") -> where("mer_id",$mer -> mer_id) -> delete();
  916. $attachmentRepository = app()->make(AttachmentRepository::class);
  917. $siteUrl = systemConfig('site_url');
  918. $merchantIntertion = app() -> make(MerchantIntention::class);
  919. $id = $merchantIntertion -> getNewQrcodeId();
  920. $name = "offlinepay_".$id.".jpg";
  921. $codeUrl = set_http_type(rtrim($siteUrl, '/') .'/offlinepay/index.html?id=' . $id, request()->isSsl() ? 0 : 1);//二维码链接
  922. $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($codeUrl, $name);
  923. if (!is_string($imageInfo)){
  924. $imageInfo['dir'] = path_to_url($imageInfo['dir']);
  925. if (strpos($imageInfo['dir'], 'http') === false) $imageInfo['dir'] = request()->domain() . $imageInfo['dir'];
  926. $attachmentRepository->create(systemConfig('upload_type') ?: 1, 0, 0, [
  927. 'attachment_category_id' => 0,
  928. 'attachment_name' => $imageInfo['name'],
  929. 'attachment_src' => $imageInfo['dir']
  930. ]);
  931. $show_src = $merchantIntertion -> show_src($imageInfo['dir'],$id);
  932. $codeInsert = [
  933. 'uid'=>$mer -> uid,
  934. 'mer_id' =>$mer -> mer_id,
  935. 'code_id'=>$id,
  936. 'qrcode_src' => $imageInfo['dir'],
  937. 'show_src' => $show_src,
  938. ];
  939. Db::name('MerchantQrcode') -> insert($codeInsert);
  940. return ['url'=>$imageInfo['dir'],'show_src'=>$show_src];
  941. }
  942. throw new ValidateException('收款码生成失败');
  943. }
  944. return $res;
  945. }
  946. /**
  947. * 根据 商户ID 获取 未删除的 商户信息
  948. * @param int $merchantId
  949. * @return MerchantEntity
  950. */
  951. public function getMerchantEntityByMerchantId(int $merchantId): MerchantEntity
  952. {
  953. $entityList = $this->getMerchantEntityListByMerchantIdList([$merchantId]);
  954. $entity = array_shift($entityList);
  955. if ($entity instanceof MerchantEntity) {
  956. return $entity;
  957. } else {
  958. /** @var MerchantEntity */
  959. return MerchantEntity::newInstance();
  960. }
  961. }
  962. /**
  963. * @param array $idList
  964. * @return MerchantEntity[]
  965. */
  966. public function getMerchantEntityListByMerchantIdList(array $idList): array
  967. {
  968. return $this->dao->getMerchantEntityListByMerchantIdList($idList);
  969. }
  970. }