ソースを参照

third merchant price

ayHaru 3 年 前
コミット
c4b32a1e85

+ 69 - 9
admin/control/merchant.php

@@ -210,7 +210,6 @@ class merchantControl extends SystemControl
     public function priceOp()
     {
         $quality = $_GET['quality'] ? $_GET['quality'] : 1;
-        $type = $_GET['type'] ?? 0;
         if (chksubmit()) {
             $mchid = $_POST['mchid'];
 
@@ -240,7 +239,7 @@ class merchantControl extends SystemControl
                 $model_merchant = Model('merchant');
                 $trans = new trans_wapper($model_merchant, __METHOD__);
                 //删除旧费率
-                $model_merchant->delPrices($mchid, $quality);
+                $model_merchant->delPrices(['mchid' => $mchid , 'quality' => $quality]);
                 //更新新费率
                 if (!empty($inserts)) {
                     $model_merchant->insertPrices($inserts);
@@ -253,17 +252,80 @@ class merchantControl extends SystemControl
             }
         }
         $mchid = $_GET['mchid'] ?? 0;
-        if($type == 7) {
-            $this->third_merchant_price($mchid);
-        }
         $goods = $this->GoodsFormat($mchid, $quality);
         Tpl::output('goods', $goods);
         Tpl::showpage('merchant.price');
     }
 
-    public function third_merchant_price($mchid)
+    public function third_merchant_priceOp()
     {
+        $mchid = $_GET['mchid'] ?? $_POST['mchid'];
+        $mod = Model('thrid_refill');
+        if(chksubmit()) {
+            //合并表单数据
+            $card_types = $_POST['cardtype'];
+            $specs = $_POST['spec'];
+            $prices = $_POST['price'];
+            $pcodes = $_POST['pcode'];
+            $quality = 1;
+
+            $params = [];
+            foreach ($card_types as $key => $card_type) {
+                $data['card_type'] = $card_type;
+                $data['spec'] = intval($specs[$key]);
+                $data['price'] = ncPriceFormat($prices[$key]);
+                $data['pcode'] = $pcodes[$key];
+                $params[] = $data;
+            }
+
+            try {
+                $model_merchant = Model('merchant');
+                $trans = new trans_wapper($model_merchant, __METHOD__);
+                foreach ($params as $param) {
+                    $insert = [];
+                    if ($param['price'] > 0) {
+                        $insert['mchid'] = $mchid;
+                        $insert['spec'] = $param['spec'];
+                        $insert['price'] = $param['price'];
+                        $insert['card_types'] = $param['card_type'];
+                        $insert['quality'] = $quality;
+                        $insert['pcode'] = $param['pcode'];
+                    }
+                    //删除旧费率
+                    $model_merchant->delPrices(['mchid' => $mchid, 'quality' => $quality, 'pcode' => $param['pcode']]);
+                    //更新新费率
+                    if(!empty($insert)) {
+                        $model_merchant->table('merchant_price')->insert($insert);
+                    }
+                }
+                $trans->commit();
+                showMessage('操作成功', 'index.php?act=merchant&op=merchant');
+            } catch (Exception $e) {
+                $trans->rollback();
+                showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error');
+            }
+        } else{
+            $condition = [];
+            if(!empty($_GET['system_code'])) {
+                $condition['system_code'] = $_GET['system_code'];
+            }
+            if (trim($_GET['product_name']) != '') {
+                $condition['product_name'] = ['like', '%' . $_GET['product_name'] . '%'];
+            }
+            $third_product = $mod->getProductList($condition,30);
 
+            $model_merchant = Model('merchant');
+            $items = $model_merchant->table('merchant_price')->where(['mchid' => $mchid, 'quality' => 1, 'card_types' => mtopcard\ThirdRefillCard])->select();
+
+            $goods = [];
+            foreach ($items as $item) {
+                $goods[$item['pcode']] = $item['price'];
+            }
+            Tpl::output('third_product', $third_product);
+            Tpl::output('goods', $goods);
+            Tpl::output('page', $mod->showpage());
+            Tpl::showpage('third.merchant.price');
+        }
     }
 
     private function GoodsFormat($mchid, $quality)
@@ -342,9 +404,7 @@ class merchantControl extends SystemControl
             return $result;
         };
 
-        $result = $merger($all_cardtype_specs, $merch_cardtype_specs);
-
-        return $result;
+        return $merger($all_cardtype_specs, $merch_cardtype_specs);
     }
 
     public function check_merchantOp()

+ 1 - 1
admin/templates/default/merchant.price.php

@@ -90,7 +90,7 @@
                 <li><a href="index.php?act=merchant&op=price&quality=5&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="5"><span>慢充两小时通道费率设置</span></a></li>
                 <li><a href="index.php?act=merchant&op=price&quality=6&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="6"><span>慢充六小时通道费率设置</span></a></li>
                 <li><a href="index.php?act=merchant&op=price&quality=7&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="7"><span>慢充二十四小时通道费率设置</span></a></li>
-                <li><a href="index.php?act=merchant&op=price&type=7&mchid=<?php echo $_GET['mchid'] ?>"><span>三方业务通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=third_merchant_price&mchid=<?php echo $_GET['mchid'] ?>"><span>三方业务通道费率设置</span></a></li>
             </ul>
         </div>
     </div>

+ 275 - 0
admin/templates/default/third.merchant.price.php

@@ -0,0 +1,275 @@
+<?php use refill\LZRefillFactory;
+
+defined('InShopNC') or exit('Access Invalid!'); ?>
+<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/recharge.css?<?php echo rand(1,10);?>" rel="stylesheet" type="text/css" id="cssfile2" />
+<style>
+    .batch {
+        vertical-align: middle;
+        display: inline-block;
+        *display: inline /*IE7*/;
+        margin-left: 4px;
+        position: relative;
+        z-index: 1;
+        *zoom: 1 /*IE7*/;
+    }
+
+    .batch i {
+        cursor: pointer;
+    }
+
+    .batch-input {
+        background-color: #FFF;
+        white-space: nowrap;
+        padding: 4px 9px;
+        border: solid 1px #BCE8F1;
+        position: absolute;
+        z-index: 1;
+        top: -70px;
+        left: -75px;
+        box-shadow: 3px 3px 0 rgba(153, 153, 153, 0.25);
+    }
+
+    .batch-input h6 {
+        font-size: 12px;
+        color: #555;
+    }
+
+    .batch-input .text {
+        vertical-align: middle;
+        clear: both;
+        padding: 0 4px;
+        vertical-align: middle;
+        margin-right: 4px;
+    }
+
+    .batch-input .arrow {
+        background: url(<?php echo SHOP_SITE_URL;?>/templates/default/images/seller/ncsc_bg_img.png) no-repeat -240px -20px;
+        display: block;
+        width: 10px;
+        height: 5px;
+        margin-left: -5px;
+        bottom: -5px;
+        left: 50%;
+        position: absolute;
+        z-index: 2;
+    }
+
+    .batch-input a.close {
+        font-size: 11px;
+        line-height: 12px;
+        color: #BCE8F1;
+        text-decoration: none;
+        background-color: #FFF;
+        text-align: center;
+        display: block;
+        width: 12px;
+        height: 12px;
+        border-radius: 7px;
+        border: solid 1px #BCE8F1;
+        top: -7px;
+        right: -7px;
+        position: absolute;
+        z-index: 2;
+    }
+
+    .text.price {
+        width: 40px;
+    }
+</style>
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3><?php echo $lang['nc_merchant']; ?></h3>
+            <ul class="tab-base">
+                <li><a href="index.php?act=merchant&op=merchant"><span><?php echo $lang['nc_manage'] ?></span></a></li>
+                <li><a href="index.php?act=merchant&op=merchant_add"><span><?php echo $lang['nc_new'] ?></span></a></li>
+
+                <li><a href="index.php?act=merchant&op=price&quality=1&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="1"><span>普通通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=2&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="2"><span>快速通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=3&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="3"><span>卡密通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=4&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="4"><span>三方通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=5&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="5"><span>慢充两小时通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=6&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="6"><span>慢充六小时通道费率设置</span></a></li>
+                <li><a href="index.php?act=merchant&op=price&quality=7&mchid=<?php echo $_GET['mchid'] ?>" class="classA" data-quality="7"><span>慢充二十四小时通道费率设置</span></a></li>
+                <li><a href="JavaScript:void(0);" class="current"><span>三方业务通道费率设置</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form method="get" name="formSearch" id="formSearch">
+        <input type="hidden" value="merchant" name="act">
+        <input type="hidden" value="third_merchant_price" name="op">
+        <input type="hidden" value="<?php echo $_GET['mchid'];?>" name="mchid">
+        <input type="hidden" name="type" value="<?php echo mtopcard\ThirdRefillCard;?>">
+        <table class="tb-type1 noborder search">
+            <tbody>
+            <tr>
+                <th><label for="product_name">产品名称</label></th>
+                <td><input type="text" value="<?php echo $_GET['product_name']; ?>" name="product_name"
+                           id="product_name" class="txt"></td>
+                <th><label for="system_code">产品编码</label></th>
+                <td><input type="text" value="<?php echo $_GET['system_code']; ?>" name="system_code"
+                           id="system_code" class="txt"></td>
+                <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
+                       title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                    <?php if ($_GET['product_name'] != '' || $_GET['system_code'] != '') { ?>
+                        <a href="index.php?act=merchant&op=third_merchant_price&mchid=<?php echo $_GET['mchid'] ?>" class="btns "
+                           title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
+                    <?php } ?>
+
+                </td>
+
+            </tr>
+            </tbody>
+        </table>
+    </form>
+    <!--   <table class="table tb-type2" id="prompt">-->
+    <!--    <tbody>-->
+    <!--      <tr class="space odd">-->
+    <!--        <th colspan="12"><div class="title">-->
+    <!--            <h5>--><?php //echo $lang['nc_prompts'];?><!--</h5>-->
+    <!--            <span class="arrow"></span></div></th>-->
+    <!--      </tr>-->
+    <!--      <tr>-->
+    <!--        <td><ul>-->
+    <!--            <li>--><?php //echo $lang['store_help1'];?><!--</li>-->
+    <!--          </ul></td>-->
+    <!--      </tr>-->
+    <!--    </tbody>-->
+    <!--  </table>-->
+    <form method="post" id="merchant_name_form">
+        <input type="hidden" name="form_submit" value="ok"/>
+        <input type="hidden" name="mchid" value="<?php echo $_GET['mchid'];?>">
+        <input type="hidden" name="quality" value="1">
+        <table class="table tb-type2 setTable" style="margin-top:20px;width:800px">
+            <thead>
+            <tr class="thead">
+                <th>产品名称</th>
+                <th>产品编码</th>
+                <th>产品面值</th>
+                <th>
+                    价格
+                    <div class="batch" style="display: inline-block"><i class="icon-edit" title="批量操作"></i>
+                        <div class="batch-input" style="display:none;">
+                            <h6>批量设置费率(百分比)</h6>
+                            <a href="javascript:void(0)" class="close">X</a>
+                            <input name="" type="number" class="text price"/>
+                            <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="price">设置</a><span
+                                    class="arrow"></span>
+                        </div>
+                    </div>
+                </th>
+            </tr>
+            </thead>
+            <tbody  class="tbody">
+            <?php if (!empty($output['third_product']) && is_array($output['third_product'])) { ?>
+                <?php foreach ($output['third_product'] as $k => $v) { ?>
+                    <tr class="trFlex">
+                        <td><?php echo $v['product_name']; ?></td>
+                        <td>
+                            <?php echo $v['system_code']; ?>
+                            <input type="hidden" name="pcode[]" value="<?php echo $v['system_code'];?>">
+                            <input type="hidden" name="cardtype[]" value="<?php echo mtopcard\ThirdRefillCard;?>">
+                        </td>
+                        <td>
+                            <?php echo $v['refill_amount']; ?>
+                            <input type="hidden" name="spec[]" value="<?php echo $v['refill_amount']; ?>">
+                        </td>
+                        <td>
+                            <input type="number" name="price[]" class="txt val"
+                                value="<?php echo $output['goods'][$v['system_code']] ?? 0;?>">
+                        </td>
+                    </tr>
+                <?php } ?>
+            <?php } else { ?>
+                <tr class="no_data">
+                    <td colspan="3"><?php echo $lang['nc_no_record']; ?></td>
+                </tr>
+            <?php } ?>
+            </tbody>
+            <?php if(!empty($output['third_product'])) {?>
+            <tr class="tfoot">
+                <td colspan="2"><a href="JavaScript:void(0);" class="btn"
+                     id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a>
+                </td>
+                <td colspan="2">
+                    <div class="pagination"><?php echo $output['page']; ?></div>
+                </td>
+            </tr>
+            <?php } ?>
+        </table>
+    </form>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
+<script>
+    $(function () {
+        $('#ncsubmit').click(function () {
+            $('#formSearch').submit();
+        });
+        $('.val').change(function () {
+            let val = $(this).val()
+            if (!val) {
+                $(this).val('0')
+            }
+        })
+        // 提交
+        $('#submitBtn').click(function () {
+            $('#merchant_name_form').submit();
+        });
+        // 表格hover时背景
+        $('.trFlex').each(function () {
+            $(this).hover(function () {
+                $(this)[0].style.backgroundColor = '#cbe9f3'
+            },function() {
+                $(this)[0].style.backgroundColor = '#fff'
+            })
+        })
+        // 批量操作
+        $('.batch > .icon-edit').click(function () {
+            $('.batch > .batch-input').hide();
+            $(this).next().show();
+        });
+        $('.batch-input > .close').click(function () {
+            $(this).parent().hide();
+        });
+        $('.batch-input > .ncsc-btn-mini').click(function () {
+            var _value = $(this).prev().val();
+            // console.log('_value', _value)
+            var trs = $(this).parents('.setTable').children('.tbody').children()
+            var trsArr = []
+            trs.each(function () {
+                let res = $(this).find('td').eq(2).text().replace(/[\  \r\n]+/g, "");
+                trsArr.push(res)
+            })
+            // console.log('trsArr', trsArr)
+            var _valArr = []
+            if (_value && _value > 0 && _value <= 200) {
+                for (var i = 0; i < trsArr.length; i++) {
+                    _valArr[i] = (parseInt(trsArr[i]) / 100 * _value).toFixed(2)
+                }
+                // console.log('_valArr', _valArr, trsArr)
+                let vals =  $(this).parents('.setTable').children('.tbody').find('.val')
+                // console.log('vals', vals)
+                for (let j= 0; j< vals.length;j++) {
+                    // console.log('vals[j]', j, vals[j], _valArr[j])
+                    vals[j].value = _valArr[j]
+                }
+                // console.log('_valArr', _valArr)
+            } else if (_value && _value == 0 && _value <= 200) {
+                for (let i = 0; i < trsArr.length; i++) {
+                    _valArr[i] = 0
+                }
+                // console.log('_valArr', _valArr, trsArr)
+                let vals =  $(this).parents('.setTable').children('.tbody').find('.val')
+                // console.log('vals', vals)
+                for (let j= 0; j< vals.length;j++) {
+                    // console.log('vals[j]', j, vals[j], _valArr[j])
+                    vals[j].value = _valArr[j]
+                }
+                // console.log('_valArr', _valArr)
+            }
+            $(this).parent().hide();
+            $(this).prev().val('');
+        });
+    });
+</script>

+ 2 - 2
data/model/merchant.model.php

@@ -32,8 +32,8 @@ class merchantModel extends Model
         return $this->table('merchant_price')->where(['mchid' => $mchid, 'spec' => $amount , 'quality' => $quality])->select();
     }
 
-    public function delPrices($mchid,$quality){
-        return $this->table('merchant_price')->where(['mchid' => $mchid , 'quality' => $quality])->delete();
+    public function delPrices($condition){
+        return $this->table('merchant_price')->where($condition)->delete();
     }
 
     public function insertPrices($params){

+ 5 - 0
data/model/thrid_refill.model.php

@@ -10,4 +10,9 @@ class thrid_refillModel extends Model
     {
         return $this->table('third_proprice')->where(['store_id' => $store_id,'goods_id' => $goods_id,'system_code' => $system_code])->field('*')->find();
     }
+
+    public function getProductList($condition, $page = null, $order = '', $field = '*', $limit = '')
+    {
+        return $this->table('third_product')->field($field)->where($condition)->order($order)->limit($limit)->page($page)->select();
+    }
 }