123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 产品
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\crm\model;
  8. use think\Db;
  9. use app\admin\model\Common;
  10. use app\admin\model\User as UserModel;
  11. use app\admin\model\File as FileModel;
  12. use think\Request;
  13. use think\Validate;
  14. use traits\model\SoftDelete;
  15. class Product extends Common
  16. {
  17. use SoftDelete;
  18. protected $deleteTime = 'delete_time';
  19. /**
  20. * 为了数据库的整洁,同时又不影响Model和Controller的名称
  21. * 我们约定每个模块的数据表都加上相同的前缀,比如CRM模块用crm作为数据表前缀
  22. */
  23. protected $name = 'crm_product';
  24. protected $createTime = 'create_time';
  25. protected $updateTime = 'update_time';
  26. protected $autoWriteTimestamp = true;
  27. /**
  28. * [getDataList 产品list]
  29. *
  30. * @param $request
  31. * @return array
  32. */
  33. public function getDataList($request)
  34. {
  35. $userModel = new \app\admin\model\User();
  36. $structureModel = new \app\admin\model\Structure();
  37. $fieldModel = new \app\admin\model\Field();
  38. $search = $request['search'];
  39. $user_id = $request['user_id'];
  40. $is_excel = $request['is_excel']; //导出
  41. $scene_id = (int)$request['scene_id'];
  42. $order_field = $request['order_field'];
  43. $order_type = $request['order_type'];
  44. $isStatus = !empty($request['is_status']) ? $request['is_status'] : 0;
  45. unset($request['scene_id']);
  46. unset($request['search']);
  47. unset($request['user_id']);
  48. unset($request['order_field']);
  49. unset($request['order_type']);
  50. unset($request['is_status']);
  51. $request = $this->fmtRequest($request);
  52. $requestMap = $request['map'] ? : [];
  53. $sceneModel = new \app\admin\model\Scene();
  54. if ($scene_id) {
  55. //自定义场景
  56. $sceneMap = $sceneModel->getDataById($scene_id, $user_id, 'product') ? : [];
  57. } else {
  58. //默认场景
  59. $sceneMap = $sceneModel->getDefaultData('crm_product', $user_id) ? : [];
  60. }
  61. if ($search) {
  62. //普通筛选
  63. $sceneMap['name'] = ['condition' => 'contains','value' => $search,'form_type' => 'text','name' => '产品名称'];
  64. }
  65. //优先级:普通筛选>高级筛选>场景
  66. $map = $requestMap ? array_merge($sceneMap, $requestMap) : $sceneMap;
  67. //高级筛选
  68. $map = where_arr($map, 'crm', 'product', 'index');
  69. if (!empty($isStatus)) {
  70. $map['product.status'] = '上架';
  71. }
  72. if (empty($map['product.delete_user_id'])) {
  73. $map['product.delete_user_id'] = 0;
  74. }
  75. //权限
  76. $a = 'index';
  77. if ($is_excel) $a = 'excelExport';
  78. $auth_user_ids = $userModel->getUserByPer('crm', 'product', $a);
  79. //过滤权限
  80. if (isset($map['product.owner_user_id']) && $map['product.owner_user_id'][0] != 'like') {
  81. if (!is_array($map['product.owner_user_id'][1])) {
  82. $map['product.owner_user_id'][1] = [$map['product.owner_user_id'][1]];
  83. }
  84. if (in_array($map['product.owner_user_id'][0], ['neq', 'notin'])) {
  85. $auth_user_ids = array_diff($auth_user_ids, $map['product.owner_user_id'][1]) ?: []; //取差集
  86. } else {
  87. $auth_user_ids = array_intersect($map['product.owner_user_id'][1], $auth_user_ids) ?: []; //取交集
  88. }
  89. unset($map['product.owner_user_id']);
  90. }
  91. $auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
  92. //负责人
  93. $authMap['product.owner_user_id'] = ['in', $auth_user_ids];
  94. //列表展示字段
  95. $indexField = $fieldModel->getIndexField('crm_product', $user_id, 1) ? : ['name'];
  96. $userField = $fieldModel->getFieldByFormType('crm_product', 'user'); //人员类型
  97. $structureField = $fieldModel->getFieldByFormType('crm_product', 'structure'); //部门类型
  98. $datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
  99. //排序
  100. if ($order_type && $order_field) {
  101. $order = $fieldModel->getOrderByFormtype('crm_product','product',$order_field,$order_type);
  102. } else {
  103. $order = 'product.update_time desc';
  104. }
  105. $join = [
  106. ['__CRM_PRODUCT_CATEGORY__ product_category', 'product_category.category_id = product.category_id', 'LEFT'],
  107. ];
  108. $map['product.delete_user_id']=0;
  109. $list = db('crm_product')->alias('product')
  110. ->join($join)
  111. ->where($map)
  112. ->where($authMap)
  113. ->limit($request['offset'], $request['length'])
  114. ->field($indexField)
  115. ->field('product.*,product_category.name as category_name')
  116. ->orderRaw($order)
  117. ->select();
  118. $dataCount = db('crm_product')->alias('product')
  119. ->where($map)->where($authMap)
  120. ->count('product_id');
  121. foreach ($list as $k=>$v) {
  122. $list[$k]['create_user_id_info'] = isset($v['create_user_id']) ? $userModel->getUserById($v['create_user_id']) : [];
  123. $list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : [];
  124. $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
  125. $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
  126. foreach ($userField as $key => $val) {
  127. $usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
  128. $list[$k][$val] = implode($usernameField, ',');
  129. }
  130. foreach ($structureField as $key => $val) {
  131. $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
  132. $list[$k][$val] = implode($structureNameField, ',');
  133. }
  134. foreach ($datetimeField as $key => $val) {
  135. $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
  136. }
  137. //产品类型
  138. $list[$k]['category_id_info'] = $v['category_name'];
  139. # 处理日期格式
  140. $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
  141. $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null;
  142. }
  143. $data = [];
  144. $data['list'] = $list;
  145. $data['dataCount'] = $dataCount ? : 0;
  146. return $data;
  147. }
  148. /**
  149. * 创建产品主表信息
  150. * @author Michael_xu
  151. * @param
  152. * @return
  153. */
  154. public function createData($param)
  155. {
  156. $fieldModel = new \app\admin\model\Field();
  157. $productCategoryModel = model('ProductCategory');
  158. $dataInfo = db('crm_product')->where(['name'=>$param['name'],'delete_user_id'=>0])->find();
  159. if(isset($dataInfo)){
  160. // 自动验证
  161. $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
  162. $validate = new Validate($validateArr['rule'], $validateArr['message']);
  163. $result = $validate->check($param);
  164. if (!$result) {
  165. $this->error = $validate->getError();
  166. return false;
  167. }
  168. }
  169. //处理部门、员工、附件、多选类型字段
  170. $arrFieldAtt = $fieldModel->getArrayField('crm_product');
  171. foreach ($arrFieldAtt as $k=>$v) {
  172. $param[$v] = arrayToString($param[$v]);
  173. }
  174. //产品分类
  175. $category_id = $param['category_id'];
  176. if (is_array($category_id)) {
  177. $param['category_id'] = $productCategoryModel->getIdByStr($category_id);
  178. $param['category_str'] = arrayToString($category_id);
  179. }
  180. if(!is_int($category_id)){
  181. $list=db('crm_product_category')->column('category_id','name');
  182. foreach ($list as $k=>$v){
  183. if($k==$param['category_id']){
  184. $param['category_id']=$v;
  185. }
  186. }
  187. }
  188. if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
  189. updateActionLog($param['create_user_id'], 'crm_product', $this->product_id, '', '', '创建了产品');
  190. $data = [];
  191. $data['product_id'] = $this->product_id;
  192. return $data;
  193. } else {
  194. $this->error = '添加失败';
  195. return false;
  196. }
  197. }
  198. /**
  199. * 编辑产品主表信息
  200. * @author Michael_xu
  201. * @param
  202. * @return
  203. */
  204. public function updateDataById($param, $product_id = '')
  205. {
  206. $userModel = new \app\admin\model\User();
  207. $dataInfo = $this->getDataById($product_id);
  208. $productCategoryModel = model('ProductCategory');
  209. if (!$dataInfo) {
  210. $this->error = '数据不存在或已删除';
  211. return false;
  212. }
  213. //判断权限
  214. $auth_user_ids = $userModel->getUserByPer('crm', 'product', 'update');
  215. if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
  216. $this->error = '无权操作';
  217. return false;
  218. }
  219. $param['product_id'] = $product_id;
  220. //过滤不能修改的字段
  221. $unUpdateField = ['create_user_id','is_deleted'];
  222. foreach ($unUpdateField as $v) {
  223. unset($param[$v]);
  224. }
  225. $fieldModel = new \app\admin\model\Field();
  226. // 自动验证
  227. // $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
  228. // $validate = new Validate($validateArr['rule'], $validateArr['message']);
  229. //
  230. // $result = $validate->check($param);
  231. // if (!$result) {
  232. // $this->error = $validate->getError();
  233. // return false;
  234. // }
  235. //处理部门、员工、附件、多选类型字段
  236. $arrFieldAtt = $fieldModel->getArrayField('crm_product');
  237. foreach ($arrFieldAtt as $k=>$v) {
  238. $param[$v] = arrayToString($param[$v]);
  239. }
  240. //产品分类
  241. $category_id = $param['category_id'];
  242. // if (is_array($category_id)) {
  243. // $param['category_id'] = $productCategoryModel->getIdByStr($category_id);
  244. // $param['category_str'] = arrayToString($category_id);
  245. // }
  246. if(!is_int($category_id)){
  247. $list=db('crm_product_category')->column('category_id','name');
  248. $param['category_id']=1;
  249. foreach ($list as $k=>$v){
  250. if($k==$category_id){
  251. $param['category_id']=$v;
  252. }
  253. }
  254. }
  255. if ($this->update($param, ['product_id' => $product_id], true)) {
  256. //修改记录
  257. updateActionLog($param['user_id'], 'crm_product', $product_id, $dataInfo, $param);
  258. $data = [];
  259. $data['product_id'] = $product_id;
  260. return $data;
  261. } else {
  262. $this->rollback();
  263. $this->error = '编辑失败';
  264. return false;
  265. }
  266. }
  267. /**
  268. * 产品数据
  269. *
  270. * @param string $id
  271. * @return Common|array|bool|\PDOStatement|string|\think\Model|null
  272. * @throws \think\db\exception\DataNotFoundException
  273. * @throws \think\db\exception\ModelNotFoundException
  274. * @throws \think\exception\DbException
  275. */
  276. public function getDataById($id = '')
  277. {
  278. $map['product_id'] = $id;
  279. $map['delete_user_id'] = 0;
  280. $dataInfo = db('crm_product')->where($map)->find();
  281. if (!$dataInfo) {
  282. $this->error = '暂无此数据';
  283. return false;
  284. }
  285. # 获取封面图片
  286. $dataInfo['cover_images'] = $this->getProductImages($dataInfo['cover_images']);
  287. # 获取详情图片
  288. $dataInfo['details_images'] = $this->getProductImages($dataInfo['details_images']);
  289. $userModel = new \app\admin\model\User();
  290. $dataInfo['create_user_id_info'] = $userModel->getUserById($dataInfo['create_user_id']);
  291. $dataInfo['category_id_info'] = db('crm_product_category')->where(['category_id' => $dataInfo['category_id']])->value('name');
  292. # 处理日期格式
  293. $fieldModel = new \app\admin\model\Field();
  294. $datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
  295. foreach ($datetimeField as $key => $val) {
  296. $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
  297. }
  298. $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
  299. $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
  300. return $dataInfo;
  301. }
  302. /**
  303. * 获取产品图片
  304. *
  305. * @param $fileIds
  306. * @return array
  307. * @throws \think\db\exception\DataNotFoundException
  308. * @throws \think\db\exception\ModelNotFoundException
  309. * @throws \think\exception\DbException
  310. */
  311. private function getProductImages($fileIds)
  312. {
  313. $files = Db::name('admin_file')->whereIn('file_id', $fileIds)->select();
  314. foreach ($files AS $key => $value) {
  315. $files[$key]['file_path'] = getFullPath($value['file_path']);
  316. $files[$key]['file_path_thumb'] = getFullPath($value['file_path_thumb']);
  317. $files[$key]['size'] = format_bytes($value['size']);
  318. }
  319. return $files;
  320. }
  321. /**
  322. * 相关产品创建(商机、合同相关产品数据)
  323. * @param types 类型
  324. * @param param['product'] 产品相关数据
  325. * @param price 产品单价
  326. * @param sales_price 销售价格
  327. * @param num 数量
  328. * @param discount 折扣
  329. * @param subtotal 小计(折扣后价格)
  330. * @param unit 单位
  331. * @param total_price 折扣后整单总价
  332. * @param discount_rate 整单折扣
  333. * @param objId 关联对象ID
  334. * @return
  335. */
  336. public function createObject($types, $param, $objId)
  337. {
  338. switch ($types) {
  339. case 'crm_business' : $db = 'crm_business_product'; $rDb = 'crm_business'; $db_id = 'business_id'; break;
  340. case 'crm_contract' : $db = 'crm_contract_product'; $rDb = 'crm_contract'; $db_id = 'contract_id'; break;
  341. default : $this->error = '参数错误'; return false; break;
  342. }
  343. $total_price = 0;
  344. if ($param['product']) {
  345. $product = [];
  346. // 启动事务
  347. Db::startTrans();
  348. try {
  349. foreach ($param['product'] as $key => $value) {
  350. $discount = 0;
  351. // $discount = ((100 - $value['discount']) > 0) ? (100 - $value['discount'])/100 : 0; //折扣
  352. $product[$key]['product_id'] = $value['product_id'];
  353. $product[$key]['price'] = $value['price']; //产品单价
  354. $product[$key]['sales_price'] = $value['sales_price']; //售价
  355. $product[$key]['num'] = $value['num']; //数量
  356. $product[$key]['discount'] = $value['discount']; //折扣
  357. $product[$key]['unit'] = $value['unit'] ? : ''; //单位
  358. $product[$key]['subtotal'] = $value['subtotal'];
  359. // $total_price += $product[$key]['subtotal'] = round(($value['price'] * $value['num']) * $discount); //总价
  360. $product[$key][$db_id] = $objId;
  361. }
  362. //删除
  363. db($db)->where([$db_id => $objId])->delete(); //原数据删除
  364. //新增
  365. db($db)->insertAll($product);
  366. $rData = [];
  367. //产品合计
  368. $rData['discount_rate'] = !empty($param['discount_rate']) ? $param['discount_rate'] : 0.00; //整单折扣
  369. $discount_rate = ((100 - $rData['discount_rate']) > 0) ? (100 - $rData['discount_rate'])/100 : 0;
  370. // $rData['total_price'] = $total_price ? $total_price*$discount_rate : '0.00'; //整单合计
  371. $rData['total_price'] = $param['total_price'] ? : '0.00'; //整单合计
  372. db($rDb)->where([$db_id => $objId])->update($rData);
  373. // 提交事务
  374. Db::commit();
  375. return true;
  376. } catch (\Exception $e) {
  377. $this->error = '产品数据创建出错';
  378. // 回滚事务
  379. Db::rollback();
  380. return false;
  381. }
  382. } else {
  383. //删除产品信息
  384. db($db)->where([$db_id => $objId])->delete();
  385. return true;
  386. }
  387. }
  388. /**
  389. * [产品统计]
  390. *
  391. * @param $param
  392. * @return mixed
  393. * @throws \think\db\exception\DataNotFoundException
  394. * @throws \think\db\exception\ModelNotFoundException
  395. * @throws \think\exception\DbException
  396. */
  397. public function getStatistics($param)
  398. {
  399. $userModel = new \app\admin\model\User();
  400. $adminModel = new \app\admin\model\Admin();
  401. $perUserIds = $userModel->getUserByPer('bi', 'product', 'read'); //权限范围内userIds
  402. $whereData = $adminModel->getWhere($param, '', $perUserIds); //统计条件
  403. $userIds = $whereData['userIds'];
  404. $between_time = $whereData['between_time'];
  405. $where = [];
  406. //时间段
  407. $where['contract.create_time'] = ['between', $between_time];
  408. $where['contract.owner_user_id'] = ['in', $userIds];
  409. $join = [
  410. ['__CRM_CONTRACT__ contract', 'contract.contract_id = a.contract_id', 'LEFT'],
  411. ['__ADMIN_USER__ user', 'user.id = contract.owner_user_id', 'LEFT'],
  412. ['__CRM_PRODUCT__ product', 'product.product_id = a.product_id', 'LEFT'],
  413. ['__CRM_PRODUCT_CATEGORY__ product_category', 'product_category.category_id = product.category_id', 'LEFT'],
  414. ];
  415. $sql = db('crm_contract_product')
  416. ->alias('a')
  417. ->where($where)
  418. ->join($join)
  419. ->field('a.*,product.name as product_name,contract.customer_id,contract.owner_user_id,contract.name as contract_name,contract.num as contract_num,product_category.name as category_id_info,user.realname,product_category.category_id')
  420. ->order('category_id,product_name')
  421. ->fetchSql()
  422. ->select();
  423. $list = queryCache($sql);
  424. foreach ($list as $k=>$v) {
  425. $customer_info = db('crm_customer')->field('customer_id,name')->where('customer_id = '.$v['customer_id'])->field('customer_id,name')->find(); //客户
  426. $list[$k]['customer_id_info'] = $customer_info ? : array();
  427. //合同
  428. $contract_info = [];
  429. $contract_info['contract_id'] = $v['contract_id'];
  430. $contract_info['name'] = $v['contract_name'];
  431. $list[$k]['contract_id_info'] = $contract_info ? : array();
  432. //产品
  433. $product_info = [];
  434. $product_info['name'] = $v['product_name'];
  435. $product_info['product_id'] = $v['product_id'];
  436. $list[$k]['product_id_info'] = $product_info ? : array();
  437. //负责人
  438. $owner_user_id_info = [];
  439. $owner_user_id_info['realname'] = $v['realname'];
  440. $list[$k]['owner_user_id_info'] = $owner_user_id_info;
  441. $list[$k]['owner_user_name'] = $owner_user_id_info['realname'];
  442. }
  443. return $list;
  444. }
  445. /**
  446. * [根据产品类别ID,查询父级ID]
  447. * @author Michael_xu
  448. * @param
  449. * @return
  450. */
  451. public function getPidStr($category_id, $idArr, $first = '')
  452. {
  453. if ($first == 1) $idArr = [];
  454. $idArr[] = $category_id;
  455. $pid = db('crm_product_category')->where(['category_id' => $category_id])->value('pid');
  456. if ($pid) {
  457. $idArr[] = $pid;
  458. $this->getPidStr($pid, $idArr);
  459. }
  460. $arr = array_reverse($idArr);
  461. $resStr = ','.implode(',',$arr).',';
  462. return $resStr;
  463. }
  464. /**
  465. * 删除当前的记录
  466. *
  467. * @overwrite 重写 traits\model\SoftDelete\delete
  468. * @param boolean $force 是否强制删除
  469. * @return integer
  470. * @author Ymob
  471. * @datetime 2019-10-24 15:02:22
  472. */
  473. public function delete($force = false)
  474. {
  475. if (false === $this->trigger('before_delete', $this)) {
  476. return false;
  477. }
  478. $name = $this->getDeleteTimeField();
  479. if ($name && !$force) {
  480. // 软删除
  481. $this->data[$name] = $this->autoWriteTimestamp($name);
  482. $this->data['delete_user_id'] = UserModel::userInfo('id');
  483. $result = $this->isUpdate()->save();
  484. } else {
  485. // 强制删除当前模型数据
  486. $result = $this->getQuery()->where($this->getWhere())->delete();
  487. }
  488. // 关联删除
  489. if (!empty($this->relationWrite)) {
  490. foreach ($this->relationWrite as $key => $name) {
  491. $name = is_numeric($key) ? $name : $key;
  492. $result = $this->getRelation($name);
  493. if ($result instanceof Model) {
  494. $result->delete();
  495. } elseif ($result instanceof Collection || is_array($result)) {
  496. foreach ($result as $model) {
  497. $model->delete();
  498. }
  499. }
  500. }
  501. }
  502. $this->trigger('after_delete', $this);
  503. // 清空原始数据
  504. $this->origin = [];
  505. return $result;
  506. }
  507. /**
  508. * 获取系统信息
  509. *
  510. * @param $id
  511. * @return array
  512. * @throws \think\db\exception\DataNotFoundException
  513. * @throws \think\db\exception\ModelNotFoundException
  514. * @throws \think\exception\DbException
  515. */
  516. public function getSystemInfo($id)
  517. {
  518. # 产品
  519. $product = Db::name('crm_product')->field(['create_user_id', 'create_time', 'update_time'])->where('product_id', $id)->find();
  520. # 创建人
  521. $realname = Db::name('admin_user')->where('id', $product['create_user_id'])->value('realname');
  522. return [
  523. 'create_user_name' => $realname,
  524. 'create_time' => date('Y-m-d H:i:s', $product['create_time']),
  525. 'update_time' => date('Y-m-d H:i:s', $product['update_time'])
  526. ];
  527. }
  528. /**
  529. * 转移
  530. *
  531. * @param $param
  532. * @return int|string
  533. * @throws \think\Exception
  534. * @throws \think\exception\PDOException
  535. */
  536. public function transfer($param)
  537. {
  538. return Db::name('crm_product')->whereIn('product_id', $param['product_id'])->update(['owner_user_id' => $param['owner_user_id']]);
  539. }
  540. }