123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- /**
- * 订单收货信息数据模型
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/11/1
- * Time: 13:53
- */
- namespace JinDouYun\Model\Order;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use JinDouYun\Dao\Order\DOrderReceive;
- use Mall\Framework\Core\StatusCode;
- class MOrderReceive
- {
- private $objDOrderReceive;
- private $cutTable = 200000;
- private $onlineUserId;
- private $onlineEnterpriseId;
- /**
- * MOrderReceive constructor.
- * @param $onlineUserId
- * @param $onlineEnterpriseId
- * @throws \Exception
- */
- public function __construct($onlineUserId, $onlineEnterpriseId)
- {
- $this->onlineUserId = $onlineUserId;
- $this->onlineEnterpriseId = $onlineEnterpriseId;
- $this->objDOrderReceive = new DOrderReceive('default');
- self::orderReceiveSubTable($onlineEnterpriseId, $onlineUserId);
- }
- /**
- * 订单收货分表
- * @param $enterpriseId (企业id)
- * @param $userId (用户id)
- * @throws \Exception
- */
- public function orderReceiveSubTable($enterpriseId, $userId)
- {
- $tableName = $this->objDOrderReceive->getTableName($this->objDOrderReceive->get_Table() . '_' . $enterpriseId, $userId, $this->cutTable);
- $this->objDOrderReceive->setTable($tableName);
- }
- /**
- * 添加订单收货信息
- * @param $params
- * @return ResultWrapper
- * @throws \Exception
- */
- public function addOrderReceive($params)
- {
- $dbResult = $this->objDOrderReceive->insert($params);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDOrderReceive->error(), ErrorCode::$dberror);
- } else {
- return ResultWrapper::success($dbResult);
- }
- }
- /**
- * 通过订单id,获取订单收货信息
- * @param $selectParams ['orderId'=>[1,2,3]]
- * @return ResultWrapper
- */
- public function getOrderReceiveByOrderIds($selectParams)
- {
- $dbResult = $this->objDOrderReceive->select($selectParams, 'id,orderId,customerId,address,realName,mobile,cityCode,districtCode,provinceCode');
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDOrderReceive->error(), ErrorCode::$dberror);
- } else {
- return ResultWrapper::success($dbResult);
- }
- }
- /**
- * 更新收货数据
- *
- * @param $data
- * @param $where
- * @return ResultWrapper
- */
- public function updateReceive($data, $where)
- {
- $dbResult = $this->objDOrderReceive->update($data, $where);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDOrderReceive->error(), ErrorCode::$dberror);
- } else {
- return ResultWrapper::success($dbResult);
- }
- }
- /**
- * Doc: (des="订单收货地址数据")
- * User: XMing
- * Date: 2020/11/4
- * Time: 10:04 上午
- * @param array $params
- * @return array
- */
- public static function buildOrderReceive(array $params): array
- {
- return [
- "no" => isset($params['no']) ? $params['no'] : '',
- //char(25) NOT NULL COMMENT '订单编号',
- "orderId" => isset($params['orderId']) ? $params['orderId'] : 0,
- //int(10) NOT NULL DEFAULT '0' COMMENT '订单Id',
- "customerId" => isset($params['customerId']) ? $params['customerId'] : 0,
- //int(10) NOT NULL DEFAULT '0' COMMENT '客户Id',
- "customerCode" => isset($params['customerCode']) ? $params['customerCode'] : '',
- //varchar(255) DEFAULT '' COMMENT '客户编码',
- "realName" => isset($params['name']) ? $params['name'] : '',
- //varchar(255) NOT NULL DEFAULT '' COMMENT '收货人姓名',
- "mobile" => isset($params['mobile']) ? $params['mobile'] : '',
- //char(11) NOT NULL DEFAULT '' COMMENT '收货人电话',
- "address" => isset($params['address']) ? $params['address'] : '',
- //varchar(255) NOT NULL DEFAULT '' COMMENT '收货详细地址',
- "provinceCode" => isset($params['provinceCode']) ? $params['provinceCode'] : '',
- //int(10) DEFAULT '0' COMMENT '省份编码',
- "cityCode" => isset($params['cityCode']) ? $params['cityCode'] : '',
- //int(10) DEFAULT '0' COMMENT '城市编码',
- "districtCode" => isset($params['districtCode']) ? $params['districtCode'] : '',
- //int(10) DEFAULT '0' COMMENT '区编码',
- "remark" => isset($params['remark']) ? $params['remark'] : '',
- //varchar(255) NOT NULL DEFAULT '' COMMENT '收货备注',
- "deleteStatus" => StatusCode::$standard,
- //tinyint(3) NOT NULL DEFAULT '5' COMMENT '是否删除 默认5 正常 4删除',
- "createTime" => time(),
- //int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
- "updateTime" => time(),
- //int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
- "detailAddress" => isset($params['detailAddress']) ? $params['detailAddress'] : '',
- //varchar(255) DEFAULT '' COMMENT '详细收货地址',
- ];
- }
- }
|