|
@@ -801,6 +801,11 @@ class Dhorder
|
|
|
'link' => Dever::url('project/database/list?project=agent&table=dh_order&menu=agent&search_option_state=1', 'manage'),
|
|
|
'name' => '返回上一页',
|
|
|
);
|
|
|
+ $audit = Dever::input('audit');
|
|
|
+ if($audit==1){
|
|
|
+
|
|
|
+ $this->show_audit($info, $result);
|
|
|
+ }
|
|
|
|
|
|
$head = array
|
|
|
(
|
|
@@ -811,7 +816,248 @@ class Dhorder
|
|
|
|
|
|
return $html;
|
|
|
}
|
|
|
+ private function show_audit($info, &$result)
|
|
|
+ {
|
|
|
+ $info['type'] = 3;
|
|
|
+
|
|
|
+ $goods = Dever::db('agent/dh_order_goods')->select(array('order_id' => $info['id'], 'status' => 1));
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->find($info['shop_id']);
|
|
|
+
|
|
|
+ list($data, $source) = Dever::load('mshop/lib/buy')->assign($goods, $info, $shop, true);
|
|
|
+
|
|
|
+ if ($info) {
|
|
|
+
|
|
|
+ $head = array('序号', '商品编号', '商品名称', '供货商', '订货总数量', '商品计量单位', '订货单总金额');
|
|
|
+ $body = array();
|
|
|
+ $i = 0;
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ foreach ($v as $v1) {
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
+ $sku = '[' . $goods_info['sku']['string'] . ']';
|
|
|
+ } else {
|
|
|
+ $sku = '';
|
|
|
+ }
|
|
|
+ $d = array
|
|
|
+ (
|
|
|
+ $i+1,
|
|
|
+ $goods_info['code'],
|
|
|
+ $goods_info['name'] . $sku,
|
|
|
+ Dever::load('mshop/lib/buy')->getSelect($source, $v1['source_id'], $v1['order_goods_id']),
|
|
|
+ $v1['num'],
|
|
|
+ $goods_info['unit'],
|
|
|
+ $v1['price'] * $v1['num'],
|
|
|
+ );
|
|
|
+
|
|
|
+ $body[] = $d;
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($goods) {
|
|
|
+ foreach ($goods as $k => $v) {
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
+ $sku = '[' . $goods_info['sku']['string'] . ']';
|
|
|
+ } else {
|
|
|
+ $sku = '';
|
|
|
+ }
|
|
|
+ $d = array
|
|
|
+ (
|
|
|
+ $i+1,
|
|
|
+ $goods_info['code'],
|
|
|
+ $goods_info['name'] . $sku,
|
|
|
+ Dever::load('mshop/lib/buy')->getSelect($source, false, $v['id']),
|
|
|
+ $v['num'],
|
|
|
+ $goods_info['unit'],
|
|
|
+ $v['price'] * $v['num'],
|
|
|
+ );
|
|
|
+
|
|
|
+ $body[] = $d;
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $btn = array();
|
|
|
+ $btn[] = array(
|
|
|
+ 'type' => 'click',
|
|
|
+ 'content' => 'setAudit()',
|
|
|
+ 'name' => '全部调整<script>function setAudit(){layer.confirm(\'确定进行此项操作吗?\', function(){var audit = $(\'.audit_set\').val();$(\'.audit\').each(function(){$(this).val(audit);layui.form.render();layer.closeAll()})})}</script>'
|
|
|
+ );
|
|
|
+ $result['商品拆单'] = array
|
|
|
+ (
|
|
|
+ 'type' => 'table',
|
|
|
+ 'head' => array('name' => '供货商:' . Dever::load('mshop/lib/buy')->getSelect($source, false, false), 'btn' => $btn),
|
|
|
+ 'content' => array
|
|
|
+ (
|
|
|
+ 'head' => $head,
|
|
|
+ 'body' => $body,
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ $url = Dever::url('lib/dhorder.audit_set_commit?json=1&order_id=' . $info['id'], 'agent');
|
|
|
+
|
|
|
+ $result['审核结果'] = array
|
|
|
+ (
|
|
|
+ 'type' => 'html',
|
|
|
+ 'content' => '<script>function saveAudit(){var goods = [];var audit = 1; var audit_text = $(".update_audit_text").val();$(".update_audit").each(function(){if ($(this).get(0).checked){audit = $(this).val()}});$(\'.audit\').each(function(){var v = $(this).val();var id = $(this).attr("id");goods.push(v + "_" + id);});layer.confirm(\'确定进行此项操作吗?\', function(){layui.form.render();var send = {};send.goods = goods.join(",");send.audit = audit;send.audit_text = audit_text;console.info(send);$.post("'.$url.'", send, function(t){t = JSON.parse(t);showYes(t)})})}</script><style>.layui-form-radio{padding-right: 0px;margin: 0px 0px 0 0;margin-left:40px}</style><div class="layui-form-item show_input"><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">审核状态</label><div style="display:inline" class="am-btn-group"><input update_type="checked" class="checkbox-checkall-0_update_audit update_audit update_value validate[required]" type="radio" name="update_audit[]" value="2" checked="" show_id="audit" autocomplete="off" id="form-validation-field-1"> 审核通过 <input update_type="checked" class="autoload checkbox-checkall-0_update_audit update_audit update_value validate[required]" type="radio" name="update_audit[]" value="3" autocomplete="off" id="form-validation-field-0"> 审核未通过 </div></div></div></div><div class="layui-form-item" style="display: block;"><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">审核备注</label></div><div><textarea style="height:100px;" update_type="value" class="update_value update_audit_text form-control layui-input validate[required]" name="update_desc"></textarea></div></div></div> <div style="text-align:left" class="layui-layer-btn layui-layer-btn-"><a class="layui-btn layui-btn-primary" onclick="saveAudit()">保存</a><a class="layui-layer-btn1" style="display:none">取消</a></div>',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function audit_set_commit_api()
|
|
|
+ {
|
|
|
+ Dever::config('base')->hook = true;
|
|
|
+
|
|
|
+
|
|
|
+ $id = Dever::input('order_id');
|
|
|
+ $goods = Dever::input('goods');
|
|
|
+ $audit = Dever::input('audit');
|
|
|
+ $audit_text = Dever::input('audit_text');
|
|
|
+
|
|
|
+ $info = Dever::db('agent/dh_order')->one($id);
|
|
|
+ if ($audit > 1 && $info && $info['status'] == 2) {
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->find($info['shop_id']);
|
|
|
+
|
|
|
+ if ($audit == 2) {
|
|
|
+ Dever::db('agent/dh_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
|
|
|
+
|
|
|
+ if (strstr($info['order_num'], '_')) {
|
|
|
+ $temp = explode('_', $info['order_num']);
|
|
|
+ $info['order_num'] = $temp[0];
|
|
|
+ $info['order_index'] = $temp[1];
|
|
|
+ } else {
|
|
|
+ $info['order_index'] = 0;
|
|
|
+ }
|
|
|
+ $goods = explode(',', $goods);
|
|
|
+ $data = $other = array();
|
|
|
+ foreach ($goods as $k => $v) {
|
|
|
+ list($source_type, $source_id, $name, $goods_id) = explode('_', $v);
|
|
|
+ $gv = Dever::db('agent/dh_order_goods')->find($goods_id);
|
|
|
+ if ($source_id > 0) {
|
|
|
+ $key = $source_type . '_' . $source_id;
|
|
|
+ $data[$key][] = array
|
|
|
+ (
|
|
|
+ 'area' => $shop['area'],
|
|
|
+ 'order_id' => $info['id'],
|
|
|
+ 'order_type' => 3,
|
|
|
+ 'order_num' => $info['order_num'],
|
|
|
+ 'order_index' => $info['order_index'],
|
|
|
+ 'type' => 1,
|
|
|
+ 'type_id' => $shop['id'],
|
|
|
+ 'source_type' => $source_type,
|
|
|
+ 'source_id' => $source_id,
|
|
|
+ 'order_goods_id' => $gv['id'],
|
|
|
+ 'goods_id' => $gv['goods_id'],
|
|
|
+ 'sku_id' => $gv['sku_id'],
|
|
|
+ 'price' => $gv['price'],
|
|
|
+ 'p_price' => $gv['price'],
|
|
|
+ 'num' => $gv['num'],
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ $other[] = $gv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->audit_action($data, $other, $info, $shop, 1);
|
|
|
+ } else {
|
|
|
+ Dever::db('agent/dh_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->find($info['shop_id']);
|
|
|
+ Dever::load('shop/lib/refund')->set('sell')->apply(1, $shop['id'], $id, false, 3, 0, '未通过审核');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Dever::url('project/database/list&project=agent&table=dh_order&menu=agent&search_option_state=1&search_option_shop_type=2&menu_id=218', 'manage');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function audit_commit()
|
|
|
+ {
|
|
|
+ $order_id = Dever::input('order_id');
|
|
|
+ $order = Dever::db('agent/dh_order')->find($order_id);
|
|
|
|
|
|
+ if (!$order || ($order && $order['status'] != 2)) {
|
|
|
+ Dever::alert('当前订单状态无法拆单');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $order['type'] = 3;
|
|
|
+
|
|
|
+ $goods = Dever::db('agent/dh_order_goods')->select(array('order_id' => $order_id));
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->find($order['shop_id']);
|
|
|
+
|
|
|
+ $data = Dever::load('mshop/lib/buy')->assign($goods, $order, $shop);
|
|
|
+
|
|
|
+ $this->audit_action($data, $goods, $order, $shop);
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+ private function audit_action($data, $goods, $order, $shop, $state = 2)
|
|
|
+ {
|
|
|
+ $send = array();
|
|
|
+
|
|
|
+ if (!$goods && $data) {
|
|
|
+
|
|
|
+ $i = $order['order_index'];
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ foreach ($v as $k1 => $v1) {
|
|
|
+ $v1['order_num'] .= '_' . $i;
|
|
|
+
|
|
|
+ $state = Dever::load('mshop/lib/buy')->createOrder($v1);
|
|
|
+ $send[$state] = $v1;
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ Dever::db('agent/dh_order')->update(array('where_id' => $order['id'], 'status' => 3));
|
|
|
+ } else {
|
|
|
+ Dever::db('agent/dh_order')->update(array('where_id' => $order['id'], 'audit' => 1));
|
|
|
+ if ($goods) {
|
|
|
+ $string = array();
|
|
|
+ foreach ($goods as $k => $v) {
|
|
|
+ $info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
|
|
|
+
|
|
|
+ if ($info['sku_name']) {
|
|
|
+ $info['name'] .= '('.$info['sku_name'].')';
|
|
|
+ }
|
|
|
+ $string[] = $info['name'];
|
|
|
+ }
|
|
|
+ $string = implode('、', $string);
|
|
|
+ if ($state == 1) {
|
|
|
+ Dever::alert('商品:'.$string.'未选择供货商');
|
|
|
+ } else {
|
|
|
+ Dever::alert('商品:'.$string.'库存不足或厂家未生产,请联系供货商备货,该订单进入重新审核状态');
|
|
|
+ }
|
|
|
+ Dever::alert('商品:'.$string.'库存不足或厂家未生产,请联系供货商备货,该订单进入重新审核状态');
|
|
|
+ } else {
|
|
|
+ if ($state == 1) {
|
|
|
+ Dever::alert('未选择供货商,该订单进入重新审核状态');
|
|
|
+ } else {
|
|
|
+ Dever::alert('供货商库存不足,请联系供货商备货,该订单进入重新审核状态');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($send) {
|
|
|
+ foreach ($send as $k => $v) {
|
|
|
+ Dever::load('mshop/lib/buy')->sendMsg($v['source_type'], $v['source_id'], $k);
|
|
|
+
|
|
|
+ $order_info = Dever::db('shop/buy_order')->find(array('id' => $k, 'clear' => true));
|
|
|
+ Dever::load('cash/lib/order')->up($order_info, 1, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function tixian()
|
|
|
{
|
|
@@ -835,6 +1081,7 @@ class Dhorder
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
public function audit_commit()
|
|
|
{
|
|
|
$order_id = Dever::input('order_id');
|
|
@@ -898,4 +1145,5 @@ class Dhorder
|
|
|
|
|
|
return 'ok';
|
|
|
}
|
|
|
+ */
|
|
|
}
|