Kaynağa Gözat

merchant goods

xiaoyu 2 yıl önce
ebeveyn
işleme
e9ec84019a

+ 37 - 0
admin/control/merchant.php

@@ -69,6 +69,43 @@ class merchantControl extends SystemControl
         Tpl::showpage('merchant.index');
     }
 
+    public function merchant_goodsOp()
+    {
+        global $config;
+        $mchid = $_GET['mchid'] ?? $_POST['mchid'];
+        $model_merchant = Model('merchant');
+        $merchant = $model_merchant->getMerchantInfo(['mchid' => $mchid], '*', true);
+        if (empty($merchant)) {
+            showMessage('机构信息有误');
+        }
+        if(chksubmit()){
+            $goods = $_POST['items'];
+            $data = [];
+            foreach ($goods as $card_type => $prices) {
+                foreach ($prices as $price) {
+                    $data[$card_type][] = intval($price);
+                }
+            }
+            wcache('merchant_goods', [$mchid => serialize($data)], 'refill-');
+            showMessage('操作成功');
+        }else{
+            $refill_specs = [
+                'chinamobile' =>  $config['refill_phone_specs'],
+                'chinaunicom' =>  $config['refill_phone_specs'],
+                'chinatelecom' => $config['refill_phone_specs']
+            ];
+
+            $merchant_goods = rcache('merchant_goods', 'refill-', $mchid);
+            $goods = $merchant_goods[$mchid] ?? serialize([]);
+            $goods = unserialize($goods);
+
+            Tpl::output('merchant', $merchant);
+            Tpl::output('goods', $goods);
+            Tpl::output('refill_specs', $refill_specs);
+            Tpl::showpage('merchant.goods');
+        }
+    }
+
     public function changeStateOp()
     {
         $mchid = intval($_GET['mchid']);

+ 183 - 0
admin/templates/default/merchant.goods.php

@@ -0,0 +1,183 @@
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.16.0/math.min.js"></script>
+<script>
+    math.config({
+        number: 'BigNumber',
+        precision: 20
+    });
+</script>
+<style>
+    .disInput {
+        background: #ccc;
+        cursor: not-allowed;
+    }
+
+    .spec_table {
+        width: 420px;
+        border-right: 1px solid #CBE9F3;
+    }
+
+    .spec_table .batch {
+        vertical-align: middle;
+        display: inline-block;
+        *display: inline
+            /*IE7*/
+        ;
+        margin-left: 4px;
+        position: relative;
+        z-index: 1;
+        *zoom: 1
+            /*IE7*/
+        ;
+    }
+
+    .spec_table .batch i {
+        cursor: pointer;
+    }
+
+    .spec_table .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);
+    }
+
+    .spec_table .batch-input h6 {
+        font-size: 12px;
+        color: #555;
+    }
+
+    .spec_table .batch-input .text {
+        vertical-align: middle;
+        clear: both;
+        padding: 0 4px;
+        margin-right: 4px;
+    }
+
+    .spec_table .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;
+    }
+
+    .spec_table .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;
+    }
+
+    .spec_table .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="JavaScript:void(0);" class="current"><span>商品编辑</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form id="price_form" enctype="multipart/form-data" method="post">
+        <input type="hidden" name="form_submit" value="ok" />
+        <input type="hidden" name="mchid" value="<?php echo $output['merchant']['mchid']; ?>" />
+        <table class="table tb-type2">
+            <tbody>
+                <tr class="noborder">
+                    <td colspan="2">
+                        <label>机构名称:</label>
+                        <label><?php echo $output['merchant']['company_name']; ?></label>
+                    </td>
+                </tr>
+
+                <tr>
+                    <td colspan="2" class="required"><label class="validation" for="password">商品:</label></td>
+                </tr>
+                <tr class="noborder" style="border-bottom: 1px solid #CBE9F3;">
+                    <?php foreach ($output['refill_specs'] as $card_type => $prices) { ?>
+                        <td>
+                            <table class="spec_table tb-type2 setTable">
+                                <tr class="w500">
+                                    <th class="w150 align-center">卡类型</th>
+                                    <th class="w150 align-center">面额</th>
+                                    <th class="w150 align-center">
+                                        开启/关闭
+                                        <div><input type="checkbox" name="chbox" value="" class="checkAllCol" data-index="<?php echo $card_type ?>"></div>
+                                    </th>
+                                </tr>
+
+                                <tbody class="tbody">
+                                    <?php foreach ($prices as $k => $price) { ?>
+                                        <tr class="w500">
+                                            <td class="w150 align-center">
+                                                <?php echo $card_type; ?>
+                                            </td>
+                                            <td class="w150 align-center">
+                                                <?php echo $price; ?>
+                                            </td>
+                                            <td class="w150 align-center tdVal">
+
+                                            <input type="checkbox" class="cellCheckBox cellCheckBox-<?php echo $k ?>" id="checkBoxList" name="items[<?php echo $card_type;?>][]" value="<?php echo "{$price}"; ?>"
+                                                <?php if(array_key_exists($card_type, $output['goods'])) {
+                                                    if(in_array($price, $output['goods'][$card_type])) {
+                                                        echo 'checked';
+                                                    }
+                                                }?>
+                                            >
+                                            </td>
+                                        </tr>
+                                    <?php } ?>
+                                </tbody>
+                            </table>
+                        </td>
+                    <?php } ?>
+                </tr>
+            </tbody>
+            <tfoot>
+                <tr class="tfoot">
+                    <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
+                </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/ajaxfileupload/ajaxfileupload.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.js"></script>
+<link href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" id="cssfile2" />
+<script type="text/javascript">
+    $(function() {
+        //按钮先执行验证再提交表单
+        $("#submitBtn").click(function() {
+            $("#price_form").submit();
+        });
+    });
+</script>

+ 8 - 4
admin/templates/default/merchant.index.php

@@ -160,17 +160,21 @@ defined('InShopNC') or exit('Access Invalid!'); ?>
                                             <a href="index.php?act=merchant&op=changeState&state=1&mchid=<?php echo $v['mchid'] ?>" style="color: green">启用机构</a>
                                         <?php } ?>
                                     </td>
-                                    <td class="align-center">
+                                    <td class="align-center w200">
                                         <a href="index.php?act=merchant&op=merchant_ctl&mchid=<?php echo $v['mchid'] ?>">
                                             充值设置
                                         </a>
-                                        <!--                            <a href="index.php?act=merchant&op=merchant_retry_times&mchid=--><?php //echo $v['mchid'] 
+                                        |
+                                        <a href="index.php?act=merchant&op=merchant_goods&mchid=<?php echo $v['mchid'] ?>">
+                                            商品设置
+                                        </a>
+                                        <!--                            <a href="index.php?act=merchant&op=merchant_retry_times&mchid=--><?php //echo $v['mchid']
                                                                                                                                             ?>
                                         <!--">-->
                                         <!--                                质量设置-->
                                         <!--                            </a>-->
                                         <!--                            |-->
-                                        <!--                            <a href="index.php?act=merchant&op=merchant_intercept&mchid=--><?php //echo $v['mchid'] 
+                                        <!--                            <a href="index.php?act=merchant&op=merchant_intercept&mchid=--><?php //echo $v['mchid']
                                                                                                                                         ?>
                                         <!--">-->
                                         <!--                                拦截设置-->
@@ -234,4 +238,4 @@ defined('InShopNC') or exit('Access Invalid!'); ?>
             $(item).text(text)
         })
     });
-</script>
+</script>

+ 10 - 2
mobile/control/refill.php

@@ -30,9 +30,17 @@ class refillControl extends merchantControl
         $goods_list = $sorter($goods_list);
 
         $result = [];
+        $mchid = $this->mchid();
+        $merchant_goods = rcache('merchant_goods', 'refill-', $mchid);
+        $goods = $merchant_goods[$mchid] ?? serialize([]);
+        $goods = unserialize($goods);
         foreach ($goods_list as $card_type => $value) {
             $key = mtopcard\scard_type($card_type);
-            $result[$key] = $value;
+            if (array_key_exists($key, $goods)) {
+                $result[$key] = $goods[$key];
+            } else {
+                $result[$key] = $value;
+            }
         }
 
         return self::outsuccess($result);
@@ -525,4 +533,4 @@ class refillControl extends merchantControl
             }
         }
     }
-}
+}