|
@@ -101,7 +101,7 @@ class ImportOrderFromCHandleData extends Command
|
|
|
$stock = Db::name("good_stock")
|
|
|
->alias("a")
|
|
|
->leftJoin("warehouse_info b", "a.wsm_code=b.wsm_code")
|
|
|
- ->where(["spuCode" => $spuCode, "a.is_del" => 0, "a.status" => 1, "b.companyNo" => $supplierNo])
|
|
|
+ ->where(["spuCode" => $spuCode, "a.is_del" => 0, "a.status" => 1,'b.wsm_type'=>5, "b.companyNo" => $supplierNo])
|
|
|
->field("a.id,a.usable_stock,a.wait_out_stock")
|
|
|
->find();
|
|
|
|
|
@@ -117,12 +117,29 @@ class ImportOrderFromCHandleData extends Command
|
|
|
$origin_price = $origin['nake_total'];
|
|
|
$sale_price = $extend_data['price'];
|
|
|
if ($goodtype == 1) {
|
|
|
-// $good = Db::name("good_ladder")
|
|
|
-// ->where(["skuCode" => $skuCode, "is_del" => 0, "status" => 1])
|
|
|
-// ->where([["min_num", "<=", $good_num]])
|
|
|
-// ->order("min_num desc")
|
|
|
-// ->find();
|
|
|
-//// if ($good == false) throw new Exception('未找到相关阶梯价格');
|
|
|
+ $good = Db::name("good_ladder")
|
|
|
+ ->where(["skuCode" => $skuCode, "is_del" => 0, "status" => 1])
|
|
|
+ ->where([["min_num", "<=", $good_num]])
|
|
|
+ ->order("min_num desc")
|
|
|
+ ->find();
|
|
|
+ if ($good == false) throw new Exception('未找到相关阶梯价格');
|
|
|
+
|
|
|
+ $sale_price = $good['sale_price'];
|
|
|
+ if ($ct['is_gold_price'] == 1) {
|
|
|
+ $gold = Db::name("gold_price1")
|
|
|
+ ->field('id,price')
|
|
|
+ ->where(["type" => $ct['noble_metal'], "is_del" => 0, "status" => 1])
|
|
|
+ ->order("addtime desc")
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ //$saleprice(最终售价) = (打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价+物流费)/(1-成本售价/100);
|
|
|
+ $sale_price = $ct['demo_fee'] / $good_num + $ct['open_fee'] / $good_num + $ct['noble_weight'] * $gold["price"] + $good['cost_fee'] * $ct['noble_weight'] + $origin['package_fee'] + $origin['mark_fee'] + $origin['cert_fee'] + $origin['nake_fee'] + $origin['delivery_fee'];
|
|
|
+
|
|
|
+// $order_rate = Db::name("cat")->where(["id" => $ct['cat_id']])->value('order_rate');
|
|
|
+// $budget = isset($order_rate) ? $order_rate / 100 : 0;
|
|
|
+
|
|
|
+ // $saleprice = $total_fee / (1 - $budget);
|
|
|
+ }
|
|
|
|
|
|
if ($is_activity == 1) {
|
|
|
$act = Db::name("activity_info")
|
|
@@ -133,6 +150,7 @@ class ImportOrderFromCHandleData extends Command
|
|
|
if ($act == false) throw new Exception('未找到相关活动价');
|
|
|
if ($act['moq_num'] > $good_num) throw new Exception('商品不满足活动价起订量' . $act['moq_num']);
|
|
|
if ($act['activity_stock'] < $good_num) throw new Exception('商品活动库存剩余' . $act['activity_stock']);
|
|
|
+ $sale_price = $act['activity_price'];
|
|
|
}
|
|
|
}
|
|
|
$cgd = [
|
|
@@ -265,73 +283,71 @@ class ImportOrderFromCHandleData extends Command
|
|
|
];
|
|
|
$vmp = Db::name('order_addr')->insert($temp, true);
|
|
|
if ($vmp > 0) {
|
|
|
- if ($is_stock == 1) {
|
|
|
- $order = Db::name("order_num")
|
|
|
- ->where(["orderCode" => $orderCode, "status" => 1])
|
|
|
- ->where([["wsend_num", ">=", 0]])
|
|
|
- ->lock(true)
|
|
|
- ->find();
|
|
|
- if ($order == false) throw new Exception('未找到可以发货得采购单数据');
|
|
|
-
|
|
|
-
|
|
|
- $num = $extend_data['num'];
|
|
|
- $outCode = makeNo("DF");
|
|
|
- $order['wsend_num'] -= $num;
|
|
|
- $order['send_num'] += $num;
|
|
|
- $or = Db::name("order_num")->save($order);
|
|
|
- if ($or == false) throw new Exception('发货地址更新失败');
|
|
|
-
|
|
|
- $tep = [
|
|
|
- "cgdNo" => $order['cgdNo'],
|
|
|
- "outCode" => $outCode,
|
|
|
- "send_num" => $num,
|
|
|
- "status" => 1,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $sen = Db::name("order_send")->save($tep);
|
|
|
- if ($sen == false) throw new Exception('发货地址添加创建失败');
|
|
|
-
|
|
|
- $cgdinfo = Db::name("purchease_order")->where(["cgdNo" => $order['cgdNo']])->find();
|
|
|
- if ($cgdinfo == false) throw new Exception('未匹配到采购数据');
|
|
|
-
|
|
|
- $out = [
|
|
|
- "orderCode" => $orderCode,
|
|
|
- "outCode" => $outCode,
|
|
|
- "apply_id" => $rm,
|
|
|
- "apply_name" => $ri,
|
|
|
- "addrid" => $vmp,
|
|
|
- "post_name" => "",
|
|
|
- "post_code" => "",
|
|
|
- "post_fee" => 0,
|
|
|
- "sendtime" => date("Y-m-d H:i:s"),
|
|
|
- "send_num" => $num,
|
|
|
- "check_num" => 0,
|
|
|
- "error_num" => 0,
|
|
|
- "wsm_code" => $cgdinfo['wsm_code'],
|
|
|
- "order_type" => 1,
|
|
|
- "status" => 1,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $ou = Db::name("order_out")->insert($out);
|
|
|
- if ($ou == false) throw new Exception('发货地址添加创建失败');
|
|
|
- else {
|
|
|
- //修改状态,添加待办
|
|
|
- ActionLog::logAdd(['id' => $rm, 'nickname' => $ri], [
|
|
|
- "order_code" => $outCode,//出库单号
|
|
|
- "status" => 0,//这里的status是之前的值
|
|
|
- "action_remark" => '',//备注
|
|
|
- "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
- ], "CKD", 0, $out);
|
|
|
-
|
|
|
- ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], [
|
|
|
- "order_type" => 'CKD',
|
|
|
- "order_code" => $outCode,//出库单号
|
|
|
- "order_id" => 0,
|
|
|
- "order_status" => 0
|
|
|
- ]);
|
|
|
- }
|
|
|
+ $order = Db::name("order_num")
|
|
|
+ ->where(["orderCode" => $orderCode, "status" => 1])
|
|
|
+ ->where([["wsend_num", ">=", 0]])
|
|
|
+ ->lock(true)
|
|
|
+ ->find();
|
|
|
+ if ($order == false) throw new Exception('未找到可以发货得采购单数据');
|
|
|
+
|
|
|
+
|
|
|
+ $num = $extend_data['num'];
|
|
|
+ $outCode = makeNo("DF");
|
|
|
+ $order['wsend_num'] -= $num;
|
|
|
+ $order['send_num'] += $num;
|
|
|
+ $or = Db::name("order_num")->save($order);
|
|
|
+ if ($or == false) throw new Exception('发货地址更新失败');
|
|
|
+
|
|
|
+ $tep = [
|
|
|
+ "cgdNo" => $order['cgdNo'],
|
|
|
+ "outCode" => $outCode,
|
|
|
+ "send_num" => $num,
|
|
|
+ "status" => 1,
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $sen = Db::name("order_send")->save($tep);
|
|
|
+ if ($sen == false) throw new Exception('发货地址添加创建失败');
|
|
|
+
|
|
|
+ $cgdinfo = Db::name("purchease_order")->where(["cgdNo" => $order['cgdNo']])->find();
|
|
|
+ if ($cgdinfo == false) throw new Exception('未匹配到采购数据');
|
|
|
+
|
|
|
+ $out = [
|
|
|
+ "orderCode" => $orderCode,
|
|
|
+ "outCode" => $outCode,
|
|
|
+ "apply_id" => $rm,
|
|
|
+ "apply_name" => $ri,
|
|
|
+ "addrid" => $vmp,
|
|
|
+ "post_name" => "",
|
|
|
+ "post_code" => "",
|
|
|
+ "post_fee" => 0,
|
|
|
+ "sendtime" => date("Y-m-d H:i:s"),
|
|
|
+ "send_num" => $num,
|
|
|
+ "check_num" => 0,
|
|
|
+ "error_num" => 0,
|
|
|
+ "wsm_code" => $cgdinfo['wsm_code'],
|
|
|
+ "order_type" => 1,
|
|
|
+ "status" => $is_stock == 1 ? 1 : 0,
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $ou = Db::name("order_out")->insert($out);
|
|
|
+ if ($ou == false) throw new Exception('发货地址添加创建失败');
|
|
|
+ else {
|
|
|
+ //修改状态,添加待办
|
|
|
+ ActionLog::logAdd(['id' => $rm, 'nickname' => $ri], [
|
|
|
+ "order_code" => $outCode,//出库单号
|
|
|
+ "status" => 0,//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
+ ], "CKD", 0, $out);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], [
|
|
|
+ "order_type" => 'CKD',
|
|
|
+ "order_code" => $outCode,//出库单号
|
|
|
+ "order_id" => 0,
|
|
|
+ "order_status" => 0
|
|
|
+ ]);
|
|
|
}
|
|
|
} else throw new Exception('发货地址添加失败');
|
|
|
}
|